summaryrefslogtreecommitdiffstats
path: root/create-psql-dumps
diff options
context:
space:
mode:
Diffstat (limited to 'create-psql-dumps')
-rwxr-xr-xcreate-psql-dumps14
1 files changed, 14 insertions, 0 deletions
diff --git a/create-psql-dumps b/create-psql-dumps
new file mode 100755
index 0000000..3356076
--- /dev/null
+++ b/create-psql-dumps
@@ -0,0 +1,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"