#!/bin/bash
#                 /usr/local/bin/synctwin
# http://crystalfaeries.net/posix/bin/synctwin
# celeste:crystalfaery 2016-03-04 22:32:07+00:00
# on host muse or faery, to be symlinked from /usr/local/bin/synchronize/:
# cd /usr/local/bin/synchronize/
# ln -s ../sync000
# ln -s ../synctwin
# ln -s ../synczzz

dryrun=""			# comment-out this assignment to perform a dry-run
dryrun="--dry-run"

# SYSTEM backup to muse's dedicated backup disk drive:	/var/cache/rsnapshot/ and /rescue
case `hostname` in
faery)
	echo "rsync -auvzH $dryrun	/boot/*	      `my_twin`:/rescue"			>> /var/log/syncup.log 2>&1
	rsync -auvzH $dryrun		/boot/*	      `my_twin`:/rescue				>> /var/log/syncup.log 2>&1
	echo "ssh -t -C -X `my_twin -u` mkdir -p	  /var/cache/rsnapshot/hourly.0/faery"	>> /var/log/syncup.log 2>&1
	ssh	  -t -C -X `my_twin -u` mkdir -p	  /var/cache/rsnapshot/hourly.0/faery	>> /var/log/syncup.log 2>&1
	#echo "rsync -auvzH $dryrun	/*	`my_twin`:/var/cache/rsnapshot/hourly.0/faery"	>> /var/log/syncup.log 2>&1
	#      rsync -auvzH $dryrun	/*	`my_twin`:/var/cache/rsnapshot/hourly.0/faery	>> /var/log/syncup.log 2>&1
	# rsnapshot hourly will do the right thing
	;;
muse)
	echo "rsync -auvzH $dryrun	/boot/*	/rescue"					>> /var/log/syncup.log 2>&1
	rsync -auvzH $dryrun		/boot/*	/rescue						>> /var/log/syncup.log 2>&1
	#echo "rsync -auvzH $dryrun	/*	/var/cache/rsnapshot/hourly.0/localhost"	>> /var/log/syncup.log 2>&1
	#      rsync -auvzH $dryrun	/*	/var/cache/rsnapshot/hourly.0/localhost		>> /var/log/syncup.log 2>&1
	# rsnapshot hourly will do the right thing
	;;
tomril)
	touch	/tmp	# not quite a noop
	# rsnapshot hourly will do the right thing
	;;
*)
	echo "$0 not yet programmed to execute on `hostname`." 1>&2
	exit -1
	;;
esac

# WEBSITE synchronization with my twin
echo "rsync -auvzH $dryrun		  /home/www/*   `my_twin`:/home/www"			>> /var/log/syncup.log 2>&1
rsync -auvzH $dryrun			  /home/www/*   `my_twin`:/home/www			>> /var/log/syncup.log 2>&1
echo "rsync -auvzH $dryrun	`my_twin`:/home/www/*		  /home/www"			>> /var/log/syncup.log 2>&1
rsync -auvzH $dryrun		`my_twin`:/home/www/*		  /home/www			>> /var/log/syncup.log 2>&1

# private BACKUPS synchronization in background makes messy log with parallel execution
echo "rsync -auvzH $dryrun --exclude=documents- --exclude=documents	/home/kahealani/*	/home/kahealani/documents/kahealani"	>> /var/log/syncup.log 2>&1
echo "rsync -auvzH $dryrun --exclude=documents- --exclude=documents	/home/kahealani/*	/home/kahealani/documents-/kahealani"	>> /var/log/syncup.log 2>&1
rsync -auvzH $dryrun --exclude=documents- --exclude=documents		/home/kahealani/*	/home/kahealani/documents/kahealani	>> /var/log/syncup.log 2>&1	&
rsync -auvzH $dryrun --exclude=documents- --exclude=documents		/home/kahealani/*	/home/kahealani/documents-/kahealani	>> /var/log/syncup.log 2>&1	&
fg;fg	#	Complete both of those parallel tasks before proceeding...

# PUBLIC BACKUPS synchronization in background makes messy log with parallel execution
echo "rsync -auvzH $dryrun /home/{audio,video}/{downloads,streams,youtube.com} /home/public-/downloads"	>> /var/log/syncup.log 2>&1
echo "rsync -auvzH $dryrun /home/{audio,video}/{downloads,streams,youtube.com} /home/public/downloads"	>> /var/log/syncup.log 2>&1
rsync -auvzH $dryrun /home/{audio,video}/{downloads,streams,youtube.com} /home/public-/downloads		>> /var/log/syncup.log 2>&1	&
rsync -auvzH $dryrun /home/{audio,video}/{downloads,streams,youtube.com} /home/public/downloads		>> /var/log/syncup.log 2>&1	&
fg;fg	#	Complete both of those parallel tasks before proceeding...



syntax highlighted by Code2HTML, v. 0.9.1