Skip to content

Instantly share code, notes, and snippets.

@tommi-lew
Created June 12, 2012 09:30
Show Gist options
  • Save tommi-lew/2916467 to your computer and use it in GitHub Desktop.
Save tommi-lew/2916467 to your computer and use it in GitHub Desktop.
Commands for managing heroku & postgres
#list current backups
heroku pgbackups --app app_name
#do a manual backup immediately
heroku pgbackups:capture --expire --app app_name
#restore postgres with dump (overwrite current state)
pg_restore --clean --no-acl --no-owner -d database_name dump_filename
#download dump and save as file
curl -O url_to_dump
#get url of latest pg backup
heroku pgbackups:url --app app_name
#create a db
createdb db_name
#list dbs
psql -l
#create a db
createdb db_name
#list dbs
psql -l
ref: https://devcenter.heroku.com/articles/upgrading-postgres-versions
#Install plugin to upgrade database
heroku plugins:install git://github.com/hgimenez/heroku-pgupgrade.git
#Create a follower for current database
heroku addons:add heroku-postgresql:zilla --follow HEROKU_POSTGRESQL_<current-color> --app <current appname>
#Wait until following is done.
heroku pg:wait
#Upgade database to 9.1
heroku pg:upgrade HEROKU_POSTGRESQL_<new-color>
#Change database to new one
heroku pg:promote HEROKU_POSTGRESQL_<new-color>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment