summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-07-09 17:02:06 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-07-09 17:02:06 +0200
commitd27b37c68725bf9a11a027e801d539cd471ffacd (patch)
treede2f0f3aa56d237f18691340700c8f349b1e0b09
parented6f1dd19591383de299d0d97ef60829db955d28 (diff)
downloadbin-d27b37c68725bf9a11a027e801d539cd471ffacd.tar.gz
bin-d27b37c68725bf9a11a027e801d539cd471ffacd.tar.xz
Add DB dumper scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xcreate-mysql-dumps10
-rwxr-xr-xcreate-psql-dumps14
2 files changed, 24 insertions, 0 deletions
diff --git a/create-mysql-dumps b/create-mysql-dumps
new file mode 100755
index 0000000..2bec29c
--- /dev/null
+++ b/create-mysql-dumps
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+mysql_opts="--defaults-file=/root/backup/mysql-defaults-backup"
+backupdir="/root/backup/mysql-dumps/"
+
+for db in $(mysql $mysql_opts -e 'show databases' -s --skip-column-names); do
+ if [[ $db != "information_schema" && $db != "performance_schema" ]]; then
+ mysqldump $mysql_opts "$db" --quick --create-options --disable-keys --add-locks --add-drop-table --lock-tables --complete-insert --skip-extended-insert | gzip > "$backupdir/$db.sql.gz"
+ fi
+done
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"