diff --git a/backup-side.sh b/backup-side.sh new file mode 100644 index 0000000..479135a --- /dev/null +++ b/backup-side.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# this script is supposed to run as cronjob on the backup side + +# Set bandwidthlimit; 1st parameter +if [ -n "$1" ];then + bw=$1 +else + bw=100000 +fi + +# copy DB +/usr/bin/rsync --bwlimit=$bw -ae 'ssh -p 64222 -i /home/nc-cloner/.ssh/id_rsa -o PreferredAuthentications=publickey' user@example.com:/home/nc-cloner/nc-bak /home/username/ + +# Copy Files +/usr/bin/rsync --bwlimit=$bw -ae 'ssh -p 64222 -i /home/nc-cloner/.ssh/id_rsa -o PreferredAuthentications=publickey' username@example.com:/home/username/ncp_data /home/username/ + +# Vars +host=localhost +user=xxxxxxxxxxxxxxxxx +pass="xxxxxxxxxxxxxxxx" +db=nextcloud + +cd /home/username/nc-bak + +DBFILE=nc-db.sql.gz +if test -f "$DBFILE"; then + /bin/gunzip nc-db.sql.gz + + # overwrite NC DB with copy from production + /usr/bin/mysql -h$host -u$user -p$pass $db < nc-db.sql + + rm nc-db.sql* +fi