Last active
December 27, 2015 08:59
-
-
Save EmmanuelKasper/7300889 to your computer and use it in GitHub Desktop.
PO
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/sh | |
# to be run as postgres user | |
# a database should be restored as posgres user with | |
# dropdb popcon | |
# createdb --encoding=UNICODE --owner=popcon popcon | |
# psql popcon < popcon.psql | |
set -e | |
do_bkp() { | |
/usr/bin/pg_dump -U postgres --column-inserts --file=/var/backups/postgres/$i.psql $i | |
} | |
databases=$(echo select datname from pg_database | \ | |
/usr/bin/psql -d postgres -U postgres -t) | |
for i in $databases; do | |
if [ "$i" != "template0" ] && [ "$i" != "template1" ]; then | |
do_bkp $i | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment