2

I have 2 heroku apps. myapp and myapp-sandbox both are branches of the same repository and have pretty much identical code-bases. I currently have the addon pgbackups doing a daily backup of myapp which is the live production site. After this backup is made I'd like to automatically reset the database on myapp-sandbox and restore the backup of myapp instead. As you've probably guessed, myapp-sandbox just provides a development sandbox for myapp and its api.

Any help much appreciated.

1 Answer 1

2

You can combine ssh, pg_dump and pg_restore to a pipe that does this in one go. Run something similar to this on the box where myapp-sandbox is on (may require some more tweaking, e.g. rename the database at the end to myapp-sandbox as it will recreate it with the original name):

ssh myapp.exmaple.com pg_dump -c -C dbname | pg_restore 
Sign up to request clarification or add additional context in comments.

2 Comments

I took another look at the docs and found this: heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-sandbox Obviously using the heroku gem, but works fine from my mac, any ideas whether this will run on a heroku instance? And whether it will work as a scheduled/cron task?
Nope sorry never used that, but I don't see an obvious reason why it shouldn't work as you like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.