server-scripts/backup-postgres
2014-10-19 17:27:33 +02:00

14 lines
313 B
Bash
Executable File

#!/bin/bash
export PGPASS=/root/.pgpass
# restore:
# psql -f $database.dump postgres
LIST=$(psql -h postgres -U postgres -At -c "select datname from pg_database order by datname;")
for d in $LIST
do
if [ "$d" != "template0" ]; then
pg_dump -h postgres -U postgres "$d" | gzip -c > "$d.dump.gz"
fi
done