11Mar/104
Western Digital Sharespace to Sharespace backup solution
There is a newer version of this script available here.
For a script running from a FreeBSD server check this script.
~~~
Lately I've been busy with making a backup script to automate the backup of a WD Sharespace drive.
This script has been made to backup between two Sharespace drives.
The script works quite simple. In a endless loop it keeps on running when you start it to the background with: ./backup.sh &
It scans for the shares on your master drive and it will Rsync it to your slave drive on the share backup.
Put this script on your slave drive in /root/backup.sh
If you decide to modify this script please leave my name in the script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/bin/sh time=5 src_ip="192.168.3.3" log="/root/backup.log" # Written by Marius van Witzenburg # http://mariusvw.com PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin PID=$$ cleanup() { rm -f ${log} return $? } s_hup() { echo -e "\n*** SIGHUP! Ignoring ***\n" cleanup #exit $? } s_int() { echo -en "\n*** SIGINT! Exiting ***\n" kill ${JOB} exit $? } s_term() { echo -en "\n*** SIGTERM! Exiting ***\n" kill ${JOB} exit $? } trap s_hup SIGHUP trap s_int SIGINT trap s_term SIGTERM echo "Having a rest for the first run..." > ${log} sleep 30 & JOB=$! wait ${JOB} echo "Running backup..." >> ${log} while [ "true" ] do for x in `ssh ${src_ip} ls -l /shares/| grep "^d" | awk '{ print $9 }'` do if [ ! -z ${x} ] then output='' if [ ! -z "`expr ${x} : '\(usb[0-9]-[0-9]share[0-9]\)'`" ] then if [ -d "/shares/${x}" ] then echo -e "USB Syncing '/shares/${x}' to '/shares/${x}'\n" >> $log rsync -qau --no-t --checksum --delete ${src_ip}:/shares/${x}/ /shares/${x}/ & 2>> ${log} 1> /dev/null JOB=$! wait ${JOB} echo -e "\n${JOB} -- finished.\n\n" >> ${log} else echo -e "Skipping USB for '/shares/${x}'\n" >> ${log} fi else echo -e "Syncing '/shares/${x}' to '/shares/backup/${x}'\n" >> $log rsync -qau --no-t --checksum --delete ${src_ip}:/shares/${x}/ /shares/backup/${x}/ & 2>> ${log} 1> /dev/null JOB=$! wait ${JOB} echo -e "\n${JOB} -- finished.\n\n" >> ${log} fi fi done message=`cat ${log}` echo -e "From: noreply@persc.nl\nTo: info@mariusvw.com\nSubject: ShareSpace backup output.\n\n${message}" | /usr/sbin/msmtp info@mariusvw.com echo -e "Waiting for cycle (${time} minutes)...\n" >> ${log} sleep `expr ${time} \* 60` & JOB=$! wait ${JOB} echo "Running cycle..." > ${log} done # EOF |
Comments and donations are more than welcome
-
eyepoker
-
eyepoker
-
http://mariusvw.com mariusvw
-
http://mariusvw.com mariusvw














