From: Sam Moore <20503628@student.uwa.edu.au> Date: Sat, 4 Aug 2012 07:27:10 +0000 (+0800) Subject: Add backup script used on superbug X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=refs%2Fhead%2Fmaster;p=matches%2Fhonours.git Add backup script used on superbug Pretty pointless but whatever --- diff --git a/superbug_backup.sh b/superbug_backup.sh new file mode 100755 index 00000000..78f8f26a --- /dev/null +++ b/superbug_backup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ "$(ps aux | grep $0)" != "" ]; then + echo "Already running!" + exit 1 +fi + +#Script to run on "superbug" to backup to BoB storage + +#target="smb://10.1.1.1/bob2%20usb%20storage/honours" +target_directory="sam\honours" +update_period=1 #Update this often in minutes + +smb_command="" #"cd $target_directory;" +for backup in $(find . -mmin -$update_period -print | grep -v "\.git" | sed 's:^\./::g'); do + #echo "$backup" + if [ "$backup" != "." ]; then + smb_command="" + if [ "$(stat $backup | head --lines=2 | tail --lines=1 | awk '{print $NF}')" == "directory" ]; then + smb_command="mkdir $target_directory\\$(echo \"$backup\" | sed 's:/:\\:g');" + else + smb_command="put \"$backup\" $target_directory\\\"$(echo $backup | sed 's:/:\\:g')\";" + fi + echo "SMB command: $smb_command" + smbclient -N //10.1.1.1/"BoB2 USB storage" -c "$smb_command" + fi +done + +exit 0