Add backup script used on superbug master
authorSam Moore <[email protected]>
Sat, 4 Aug 2012 07:27:10 +0000 (15:27 +0800)
committerSam Moore <[email protected]>
Sat, 4 Aug 2012 07:27:10 +0000 (15:27 +0800)
Pretty pointless but whatever

superbug_backup.sh [new file with mode: 0755]

diff --git a/superbug_backup.sh b/superbug_backup.sh
new file mode 100755 (executable)
index 0000000..78f8f26
--- /dev/null
@@ -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

UCC git Repository :: git.ucc.asn.au