Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Created October 18, 2013 13:52
Show Gist options
  • Select an option

  • Save stevenyap/7041858 to your computer and use it in GitHub Desktop.

Select an option

Save stevenyap/7041858 to your computer and use it in GitHub Desktop.

Revisions

  1. stevenyap revised this gist Dec 20, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Heroku Database.md
    Original 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>
  2. stevenyap revised this gist Dec 20, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions Heroku Database.md
    Original 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>
    ```
  3. stevenyap revised this gist Oct 19, 2013. 1 changed file with 22 additions and 7 deletions.
    29 changes: 22 additions & 7 deletions Heroku Database.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    ## Exporting Heroku PG DB to local
    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/importing pg db
    https://devcenter.heroku.com/articles/pgbackups
    https://devcenter.heroku.com/articles/heroku-postgres-import-export
    ---

    ## 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 **

    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

    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'
    ```
  4. stevenyap revised this gist Oct 19, 2013. 1 changed file with 25 additions and 0 deletions.
    25 changes: 25 additions & 0 deletions Heroku Database.md
    Original 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
  5. stevenyap created this gist Oct 18, 2013.
    7 changes: 7 additions & 0 deletions Heroku Database.md
    Original 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