3 if [ "$(ps aux | grep $0)" != "" ]; then
4 echo "Already running!"
8 #Script to run on "superbug" to backup to BoB storage
10 #target="smb://10.1.1.1/bob2%20usb%20storage/honours"
11 target_directory="sam\honours"
12 update_period=1 #Update this often in minutes
14 smb_command="" #"cd $target_directory;"
15 for backup in $(find . -mmin -$update_period -print | grep -v "\.git" | sed 's:^\./::g'); do
17 if [ "$backup" != "." ]; then
19 if [ "$(stat $backup | head --lines=2 | tail --lines=1 | awk '{print $NF}')" == "directory" ]; then
20 smb_command="mkdir $target_directory\\$(echo \"$backup\" | sed 's:/:\\:g');"
22 smb_command="put \"$backup\" $target_directory\\\"$(echo $backup | sed 's:/:\\:g')\";"
24 echo "SMB command: $smb_command"
25 smbclient -N //10.1.1.1/"BoB2 USB storage" -c "$smb_command"