Restoring backups

suggest change
psql < backup.sql

A safer alternative uses -1 to wrap the restore in a transaction. The -f specifies the filename rather than using shell redirection.

psql -1f backup.sql

Custom format files must be restored using pg_restore with the -d option to specify the database:

pg_restore -d DATABASE DATABASE.pgsql

The custom format can also be converted back to SQL:

pg_restore backup.pgsql > backup.sql

Usage of the custom format is recommended because you can choose which things to restore and optionally enable parallel processing.

You may need to do a pg_dump followed by a pg_restore if you upgrade from one postgresql release to a newer one.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents