summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord. johnson <fenris02@fedoraproject.org>2015-07-10 08:58:51 -0500
committerd. johnson <fenris02@fedoraproject.org>2015-07-10 08:58:51 -0500
commit812beeab757399df257500f1939655077826e340 (patch)
tree724caa2cb751dd8d6e6f5c0d11c630e622a22da9
parentcd0882ffb4e8a3398f4ef8c85a2f8f01ad5f2e37 (diff)
downloadcleanup-812beeab757399df257500f1939655077826e340.tar.gz
cleanup-812beeab757399df257500f1939655077826e340.tar.xz
cleanup-812beeab757399df257500f1939655077826e340.zip
adding mysql-backup script for reference
-rwxr-xr-xmysql-backup.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-backup.sh b/mysql-backup.sh
new file mode 100755
index 0000000..97799de
--- /dev/null
+++ b/mysql-backup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+DC=$(/bin/date +%Y%m%d)
+BK_DIR="$HOME/MySQL/mysql-backup-$DC"
+
+##mysqldump -A --opt --add-drop-database --order-by-primary --hex-blob |gzip -9 > mysql-backup-$DC.sql.gz
+
+[ -d $BK_DIR ] || mkdir -p $BK_DIR
+cd $BK_DIR
+
+for TBL in $( mysql -e 'show databases;' |cat ) ; do
+ echo "Backing up $TBL"
+ /usr/bin/mysqldump --opt --add-drop-database --order-by-primary --hex-blob $TBL > $BK_DIR/$TBL.sql
+done
+
+cd $BK_DIR/..
+echo "Archiving to mysql-backup-$DC"
+zip -9myroq $BK_DIR mysql-backup-$DC
+
+#EOF