Last active
June 27, 2020 10:50
-
-
Save rkalkani/2eeb9699732b74c6d32fd533c1959ed4 to your computer and use it in GitHub Desktop.
Snippets to backup/restore postgresql database from docker container
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
# Backup postgresql db from postgresql docker container | |
docker exec -i ${CONTAINER_NAME} pg_dump -U ${USERNAME} -w ${DB_NAME} -O -x | gzip -9 > $(date +%Y%m%d_%H%M%S)_${DB_NAME}.pgsql.gz | |
# Restore the postgresql db to postgresql docker container | |
gunzip -c ${FILENAME}.pgsql.gz | sudo docker exec -i ${CONTAINER_NAME} pg_restore -U ${USERNAME} -w -d ${DB_NAME} -C --clean -Fc -O -x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment