#!/bin/bash

#taken from
#http://www.howtogeek.com/175008/the-non-beginners-guide-to-syncing-data-with-rsync/


#copy old time.txt to time2.txt

yes | cp ~/backup/time.txt ~/backup/time2.txt

#overwrite old time.txt file with new time

echo `date +”%F_%H %M%p”` > ~/RSYNC-BACKUPS/time.txt

#make the log file

echo “” > ~/backup/rsync-`date +”%F-%I%p”`.log

#rsync command

rsync -avzhPR --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --delete --stats --log-file=~/backup/rsync-`date +”%F-%I%p”`.log --exclude-from '~/exclude.txt' --link-dest=/home/geek2/files/`cat ~/backup/time2.txt` -e 'ssh -p 12345' /home/geek/files/ geek2@10.1.1.1:/home/geek2/files/`date +”%F-%I%p”`/

#don’t forget to scp the log file and put it with the backup

scp -P 12345 ~/backup/rsync-`cat ~/backup/time.txt`.log geek2@10.1.1.1:/home/geek2/files/`cat ~/backup/time.txt`/rsync-`cat ~/backup/time.txt`.log

