Heroku database backup restore
Sometimes estrange things happend and we mess up our staging or production environments.
This is when knowing how to do a manual backup comes in handy.
heroku pgbackups:capture
I do this all the time before pushing my new code, or before opening a rails console.
I also like to do a heroku maintenance:on before doing a big push, I mean, something that changes a lot of code, database migrations and perhaps rake tasks.
If something goes wrong, you could do a code rollback easilly, but you just migrated the schema or changed its contents with a rake task, this are the times when knowing how to restore the database comes in handy.
# returns the amazon s3 url of the lates backup if [backup name] its not provided
heroku pgbackups:url [Backup name]
and
# restores the database with a dump file publicly accessible by the url
heroku pgbackups:restore DATABASE_NAME URL
Knowing those two methods, I like to do this
heroku pgbackups:restore JADE `heroku pgbackups:url b406 --remote production` --remote production
Written by Miguel
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Heroku
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#