#! /bin/bash

NAME="not valid"
ping -c 1 hecate.local 1> /dev/null 2> /dev/null
if [ $? -eq 0 ]; then 
	NAME="hecate.local"
else 
	ping -c 1 10.8.0.2 1> /dev/null 2> /dev/null
	if [ $? -eq 0 ]; then 
		NAME="10.8.0.2"
	else 
		echo "$(date    ) failed, couldnt get to the host" >> ~/Documents/masters/cronlog
		echo "try connecting to the vpn"
		exit
	fi
fi
 

echo "starting rsync"
rsync -av --progress ~/Documents/masters $NAME:/mnt/external/data_dump/uni_backups
echo "rsync completed, exit code $?"
echo "$(date    ) script with name $NAME" >> ~/Documents/masters/cronlog
ssh natalie@$NAME "chmod -R 0747 /mnt/external/data_dump/uni_backups/masters"
echo "all done!"

