Created
January 4, 2014 13:25
-
-
Save dkastl/8255309 to your computer and use it in GitHub Desktop.
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 | |
MYDATE=$(date +%d-%m-%Y) | |
for PORT in 5432 5433 5434 | |
do | |
echo "Backups on port $PORT" | |
export PGPORT=$PORT | |
LIST=$(psql -l | awk '{ print $1 }' | grep '^[a-z]' | grep -v template | grep -v postgres) | |
for ITEM in $LIST | |
do | |
NAME=${ITEM}-${MYDATE}.dmp | |
echo "Backing up $ITEM to $NAME" | |
pg_dump -Fc -f $NAME ${ITEM} | |
done | |
done | |
# To restore any of the dumps, you can do: | |
#createdb foo; pg_restore foo.dmp | psql foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment