Skip to content

Instantly share code, notes, and snippets.

@jeremykendall
Last active April 27, 2021 20:27

Revisions

  1. jeremykendall revised this gist Sep 25, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions postgres-dump-restore.markdown
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,5 @@ This syntax allows importing to a database with the name of your choice.

    ## Reference

    [`pg_dump` documentation](http://www.postgresql.org/docs/9.4/static/app-pgdump.html)
    [`pg_restore` documentation](http://www.postgresql.org/docs/9.4/static/app-pgrestore.html)
    * [`pg_dump` documentation](http://www.postgresql.org/docs/9.4/static/app-pgdump.html)
    * [`pg_restore` documentation](http://www.postgresql.org/docs/9.4/static/app-pgrestore.html)
  2. jeremykendall revised this gist Sep 25, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion postgres-dump-restore.markdown
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    `pg_dump -U [superuser] -Fc [dbname] > db.dump`

    [`pg_dump` documentation](http://www.postgresql.org/docs/9.4/static/app-pgdump.html)


    ## Import

    @@ -18,4 +18,7 @@ This syntax allows importing to a database with the name of your choice.

    `pg_restore --clean --if-exists --no-acl --no-owner --verbose -d [dbname] -U [superuser] db.dump`

    ## Reference

    [`pg_dump` documentation](http://www.postgresql.org/docs/9.4/static/app-pgdump.html)
    [`pg_restore` documentation](http://www.postgresql.org/docs/9.4/static/app-pgrestore.html)
  3. jeremykendall created this gist Sep 25, 2015.
    21 changes: 21 additions & 0 deletions postgres-dump-restore.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Postgres Export and Import

    ## Export

    `pg_dump -U [superuser] -Fc [dbname] > db.dump`

    [`pg_dump` documentation](http://www.postgresql.org/docs/9.4/static/app-pgdump.html)

    ## Import

    This syntax allows importing to a database with the name of your choice.

    ### Create the database (if it does not exist):

    `createdb -T template0 [dbname]`

    ### Import:

    `pg_restore --clean --if-exists --no-acl --no-owner --verbose -d [dbname] -U [superuser] db.dump`

    [`pg_restore` documentation](http://www.postgresql.org/docs/9.4/static/app-pgrestore.html)