--- /dev/null
+#!/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