created backup/restore scripts
authorLars Kneschke <l.kneschke@metaways.de>
Wed, 25 Feb 2015 16:13:08 +0000 (17:13 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 6 Mar 2015 10:14:26 +0000 (11:14 +0100)
Change-Id: I573990fc1b3411aca4e995b18ac99b0027e18bd0
Reviewed-on: http://gerrit.tine20.com/customers/1694
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
scripts/backup/backup-config.sh [new file with mode: 0644]
scripts/backup/backup-data.sh [new file with mode: 0644]
scripts/backup/restore-config.sh [new file with mode: 0644]
scripts/backup/restore-data.sh [new file with mode: 0644]

diff --git a/scripts/backup/backup-config.sh b/scripts/backup/backup-config.sh
new file mode 100644 (file)
index 0000000..6338487
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+BACKUP_PATH=$(mktemp --directory --tmpdir=/tmp/)
+TODAY=$(date +"%Y-%m-%d")
+
+test -d /var/lib/tine20/backup/$TODAY || mkdir -p /var/lib/tine20/backup/$TODAY
+
+cp -ra /etc/tine20/config.inc.php /var/lib/tine20/backup/$TODAY
\ No newline at end of file
diff --git a/scripts/backup/backup-data.sh b/scripts/backup/backup-data.sh
new file mode 100644 (file)
index 0000000..8282598
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+BACKUP_PATH=$(mktemp --directory --tmpdir=/tmp/)
+TODAY=$(date +"%Y-%m-%d")
+
+if [ ! -x /usr/bin/innobackupex ]; then
+    echo "innobackupex not found exiting"
+    exit 1
+fi
+
+if [ ! -x /usr/bin/xtrabackup ]; then
+    echo "xtrabackup not found exiting"
+    exit 1
+fi
+
+# MyISAM and Innodb tables
+innobackupex --defaults-extra-file /etc/tine20/xtrabackup.cnf --no-timestamp $BACKUP_PATH/mysql
+
+# prepare Innodb tables
+xtrabackup --prepare --target-dir=$BACKUP_PATH/mysql
+xtrabackup --prepare --target-dir=$BACKUP_PATH/mysql
+
+
+(cd $BACKUP_PATH/mysql/ && tar cjf ../full_mysql.tar.bz2 .)
+
+rm -rf $BACKUP_PATH/mysql
+
+(cd /var/lib/tine20/files; tar cjf $BACKUP_PATH/tine20_files.tar.bz2 .)
+
+test -d /var/lib/tine20/backup/$TODAY || mkdir -p /var/lib/tine20/backup/$TODAY
+
+mv $BACKUP_PATH/full_mysql.tar.bz2 /var/lib/tine20/backup/$TODAY
+mv $BACKUP_PATH/tine20_files.tar.bz2 /var/lib/tine20/backup/$TODAY
+
+rm -rf $BACKUP_PATH
+
diff --git a/scripts/backup/restore-config.sh b/scripts/backup/restore-config.sh
new file mode 100644 (file)
index 0000000..d157889
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+SOURCE_PATH=$1
+
+if [ -e $SOURCE_PATH/config.inc.php ]; then
+    cp $SOURCE_PATH/config.inc.php /etc/tine20/config.inc.php
+    chown root:www-data /etc/tine20/config.inc.php
+    chmod 0660 /etc/tine20/config.inc.php
+fi
\ No newline at end of file
diff --git a/scripts/backup/restore-data.sh b/scripts/backup/restore-data.sh
new file mode 100644 (file)
index 0000000..b7b788c
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+SOURCE_PATH=$1
+
+(cd /var/lib/mysql/; tar xf $SOURCE_PATH/full_mysql.tar.bz2 .)
+(cd /var/lib/tine20/files; tar xf $SOURCE_PATH/tine20_files.tar.bz2 .)
+
+chown -R mysql:mysql /var/lib/mysql/*
+chown -R www-daza:www-data /var/lib/tine20/files/*
\ No newline at end of file