pgbackup.sh 302 Bytes
Newer Older
1
2
3
4
5
6
7
#!/bin/sh

for DB in $(sudo -u postgres psql -l 2>/dev/null | cut -d" " -f 2 | grep -v -- "---" | grep -v rows | grep -v '^[\t ]*$' | grep -v template)
do
	sudo -u postgres pg_dump -o $DB | gzip -c -- > ${DB}.sql.gz
done

8
sudo -u postgres pg_dumpall -g -U postgres -o | gzip -c -- > pg_dumpall.sql.gz
9