Created
December 4, 2017 09:18
-
-
Save zukka77/db57eb9570008b466dcfc89471407587 to your computer and use it in GitHub Desktop.
pg_dump script
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 -e | |
DATA=$(date -I) | |
DEST_DIR=${DEST_DIR} | |
CURRENT_DIR="${DEST_DIR}/${DATA}" | |
mkdir -p $CURRENT_DIR | |
cd $CURRENT_DIR | |
pg_dumpall -Upostgres -g > global.dmp | |
for db in $(psql -Upostgres -At -c 'select datname from pg_database where not datistemplate and datallowconn order by datname');do | |
echo backup ${db} | |
pg_dump -Upostgres -Fc $db > ${db}.dump | |
done | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment