Skip to content

Instantly share code, notes, and snippets.

@lin
Created April 8, 2016 07:40
Show Gist options
  • Select an option

  • Save lin/48eb91fe47009f4e7c05e8f3ef09e3ca to your computer and use it in GitHub Desktop.

Select an option

Save lin/48eb91fe47009f4e7c05e8f3ef09e3ca to your computer and use it in GitHub Desktop.

Based on this article.

1, backup database using:

pg_dump -U ubuntu app_development -f ~/Downloads/app.sql

2, upload to the server.

scp -i ~/.ssh/app.pem ~/Downloads/app.sql ubuntu@[ip]:/var/www/db

3, drop db and create db

dropdb 'app_production'
createbd 'app_production'

4, restore the db

psql -U ubuntu -d app_production -f app.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment