summaryrefslogtreecommitdiffstats
path: root/create-psql-dumps
blob: 3356076e268d4b7e8603e9ab56c24c1a770aacd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

backupdir="/root/backup/psql-dumps"

DBLIST=($(sudo -u postgres -i psql postgres -qt -c 'SELECT datname from pg_database'))
for d in "${DBLIST[@]}"; do
	if [[ $d =~ template[01] ]]; then
		continue;
	fi
	#echo "db = $d";
	sudo -u postgres -i pg_dump --serializable-deferrable -Fc "$d" > "$backupdir/$d.dump"
done

sudo -u postgres -i pg_dumpall --globals-only > "$backupdir/globals.sql.dump"