Last active
July 26, 2020 17:32
-
-
Save vishin-pavel/32bd56ecbdf9b3e050c683faa67f0467 to your computer and use it in GitHub Desktop.
Backup/Restore your postgres databases in docker
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 characters
#Backup your databases | |
docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql |
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 characters
#Backup and gzip your databases | |
docker exec -t your-db-container pg_dumpall -c -U postgres | gzip > /var/data/postgres/backups/dump_date +%d-%m-%Y"_"%H_%M_%S.gz |
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 characters
#Restore your databases | |
cat your_dump.sql | docker exec -i your-db-container psql -U postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment