Created
December 19, 2022 05:33
-
-
Save ktwrd/7c612de69f3298cbf072e2eeaefd3ac9 to your computer and use it in GitHub Desktop.
Backup PostgreSQL database running with Docker
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
#!/bin/bash | |
TIMESTAMP=$(date +"%Y%m%d_%H%M%s") | |
FILENAME="/var/lib/postgresql/data-backup/$TIMESTAMP.bak" | |
_ROLE="postgres" | |
_ENCODING="UTF8" | |
_DBNAME="mastodon" | |
docker exec -it mastodon_db_1 \ | |
pg_dump --username "postgres" \ | |
--no-password \ | |
--file "$FILENAME" \ | |
--role "$_ROLE" \ | |
--format=c \ | |
--blobs \ | |
--compress "3" \ | |
--section=pre-data \ | |
--section=data \ | |
--section=post-data \ | |
--encoding "$_ENCODING" \ | |
"$_DBNAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment