Neue Datei hochladen

This commit is contained in:
Daniel Schubert 2020-02-05 10:04:47 +00:00
parent 6405bf424d
commit e17893ae70
1 changed files with 33 additions and 0 deletions

33
backup-side.sh Normal file
View File

@ -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