-
-
Save ajepe/987deaeb24d76e83120c63d2e5121ed1 to your computer and use it in GitHub Desktop.
Backup and restore in PostgreSQL using compressed backups.
This file contains 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 characters
# List databases | |
sudo su postgres | |
psql | |
\list | |
# Create a compressed backup | |
sudo su postgres | |
pg_dump -Fc <database_name> > <file> | |
# Example | |
pg_dump -Fc geartranslations_development > /tmp/backup.dump | |
# Restore a plain-text backup | |
# TABLES THAT ALREADY EXIST WILL NOT BE MODIFIED. | |
sudo su postgres | |
pg_restore -Fc -d <database_name> <backup_file> | |
# Example | |
pg_restore -Fc -d geartranslations_development /tmp/backup.dump | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment