Forked from mcandre/postgresql-backup-and-restore.md
Created
October 6, 2022 22:24
-
-
Save 1v/a09ea21b812f762432ed848972dba994 to your computer and use it in GitHub Desktop.
Revisions
-
Andrew revised this gist
Apr 9, 2020 . No changes.There are no files selected for viewing
-
Andrew revised this gist
Apr 9, 2020 . No changes.There are no files selected for viewing
-
Andrew revised this gist
Apr 9, 2020 . 1 changed file with 2 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,18 +1,13 @@ # POSTGRESQL BACKUP AND RESTORE ```console $ pg_dumpall --clean -U <user> -f backup.sql $ psql -U <user> -f backup.sql ``` # Warnings * A PostgreSQL user with administrative privileges is required. * Using `pg_dump` instead of `pg_dumpall` results in role privileges being reset to nothing. * If you forget the `--clean` / `-c` flag to `pg_dumpall`, then the backup SQL script will not be idempotent, and will collide and error with any existing databases. * Using `pg_restore` instead of `psql` will reject the plain SQL backup format. -
Andrew created this gist
Apr 9, 2020 .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,18 @@ # Backup ```console $ pg_dumpall --clean -U <user> -f backup.sql ``` # Restore ```console $ psql -U <user> -f backup.sql ``` # Warnings * A PostgreSQL user with administrative privileges is required. * Using `pg_dump` instead of `pg_dumpall` results in role privileges being reset to nothing. * If you forget the `--clean` / `-c` flag to `ph_dumpall`, then the backup SQL script will not be idempotent, and will collide and error with any existing databases. * Using `pg_restore` instead of `psql` will reject the plain SQL backup format.