Last active
November 5, 2023 22:32
-
-
Save wikiti/22ebd04115448aef786ad5c123dc666c 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