PostgreSQL Backups and Migration: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
Line 6: Line 6:
</syntaxhighlight>
</syntaxhighlight>


The password can be included in the command above, otherwise you'll be prompted for the password.<ref>[http://www.postgresql.org/docs/8.3/static/backup-dump.html SQL Dump] PostgreSQL 8.3.23 documetation</ref>
The password can be included in the command above, otherwise you'll be prompted for the password. <ref>[http://www.postgresql.org/docs/8.3/static/backup-dump.html SQL Dump] - PostgreSQL 8.3.23 documetation</ref>


The `-a` option will dump only the data in the database, not the structure.
The `-a` option will dump only the data in the database, not the structure. <ref>[http://www.postgresql.org/docs/8.3/static/app-pgdump.html `pg_dump`] - PostgreSQL 8.3.23 documentation</ref>


It's also possible to compress the dump:
It's also possible to compress the dump:

Revision as of 17:50, 16 February 2016

database snapshot

$ pg_dump -h hostname - d dbname -U username > mysnapshot.sql

The password can be included in the command above, otherwise you'll be prompted for the password. [1]

The -a option will dump only the data in the database, not the structure. [2]

It's also possible to compress the dump:

$ pg_dump -h hostname - d dbname -U username | gzip > mysnapshot.gz
$ gunzip -c mysnapshot.gz | psql dbname

Restoring a dump

$ psql dbname < mysnapshot.sql

Notes

  1. SQL Dump - PostgreSQL 8.3.23 documetation
  2. pg_dump - PostgreSQL 8.3.23 documentation