Created
October 18, 2013 13:52
-
-
Save stevenyap/7041858 to your computer and use it in GitHub Desktop.
Revisions
-
stevenyap revised this gist
Dec 20, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,6 +47,7 @@ heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/me/items/3H0q/mydb.d ``` ## Delete a Postgres Backup ```sh heroku pgbackups # To see a list of all backups heroku pgbackups:destroy <BACKUP_ID> -
stevenyap revised this gist
Dec 20, 2013 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,3 +45,9 @@ Next, call Heroku to download the dump and then restore it: ```sh heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/me/items/3H0q/mydb.dump' ``` ## Delete a Postgres Backup ```sh heroku pgbackups # To see a list of all backups heroku pgbackups:destroy <BACKUP_ID> ``` -
stevenyap revised this gist
Oct 19, 2013 . 1 changed file with 22 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ Note: You need to have to Heroku PGBackup addon first `heroku addons:add pgbackups`.. ## Importing Heroku PG DB to local Creates the backup on heroku first: @@ -23,10 +25,23 @@ Remove the dump: rm latest.dump ``` --- ## Exporting local to Heroku Create your DB dump locally: ```sh pg_dump -Fc --no-acl --no-owner -h localhost mydbname > mydb.dump ``` **Add PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" in .bash_profile if you encountered version does not match error when doing pg_dump ** Upload mydb.dump to your S3 or a remote FTP. **Note: remember to set permission for file uploaded to S3** Next, call Heroku to download the dump and then restore it: ```sh heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/me/items/3H0q/mydb.dump' ``` -
stevenyap revised this gist
Oct 19, 2013 . 1 changed file with 25 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,28 @@ ## Exporting Heroku PG DB to local Creates the backup on heroku first: ```sh heroku pgbackups:capture ``` Download it to local via curl: ```sh curl -o latest.dump `heroku pgbackups:url` ``` Restore it: ```sh pg_restore --verbose --clean --no-acl --no-owner -h localhost -d mydbname latest.dump ``` Remove the dump: ```sh rm latest.dump ``` ## exporting/importing pg db https://devcenter.heroku.com/articles/pgbackups https://devcenter.heroku.com/articles/heroku-postgres-import-export -
stevenyap created this gist
Oct 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ ## exporting/importing pg db https://devcenter.heroku.com/articles/pgbackups https://devcenter.heroku.com/articles/heroku-postgres-import-export Note: remember to set permission for file uploaded to S3 Note: we don't have user so it can be omitted in cmd-line Note: add PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" in .bash_profile if you encountered version does not match error when doing pg_dump