0

I would like to create a script that would make a dump of a postgresql DB on heroku and download it to my local server. I using windows server 2008 R2 and would assume that this would be activated with scheduler. On the local server installed is ruby 1.93 and chocolately (run curl on a PC).

I am assuming that the script would be a ruby file and have the commands to both create a backup and and then use a curl command to download it. The latest backup would be the only one downloaded

The commands would be something like
heroku pgbackups:capture --expire -a appname
curl -o latest.dump heroku pgbackups:url

thanks in advance

maggs
  • 125
  • 1
  • 13
  • 1
    Easiest way I can think of is to use the Heroku CLI and just run a bunch of command-line calls. Bash would better for that, but you can use back-tics in a ruby file, too. Otherwise, go hunting for gems to interact with Heroku. There should be one or two out there. – Narfanator Jul 22 '14 at 06:48
  • Hi Narfanator If I can I want to have a script that is automatically started by scheduler with the heroku pgbackups:capture --expire -a appname and curl -o latest.dump heroku pgbackups:url. I have had a look at backtics etc but am not sure what the next step is. thanks – maggs Jul 23 '14 at 02:58
  • You want to look into the Windows bash language, one way or the other. Ruby backtics are a short hand for system calls - http://stackoverflow.com/questions/6338908/ruby-difference-between-exec-system-and-x-or-backticks – Narfanator Jul 23 '14 at 17:26
  • Heroku tools for windows, including the CLI: https://toolbelt.heroku.com/windows – Narfanator Jul 23 '14 at 17:28
  • Your big issue is that the Windows command prompt isn't Unix-based (everything else is, given that everything else consist of Unix distros, Linux distros, and Mac, which is based on Unix). Honestly, if you can run this job on *not* Windows, that might be easier, especially if you don't have access to anyone who's already familiar with the windows command prompts. – Narfanator Jul 23 '14 at 17:30
  • Another method would be to have a scheduled job that runs on *Heroku* that uploads the database dump to a known S3 location, and then all your local job has to do is download that file periodically, which you can do with your curl-alternative. – Narfanator Jul 23 '14 at 17:33

1 Answers1

1

The easiest way would be to get curl for your Windows machine at http://curl.haxx.se

sorpaas
  • 43
  • 6