#!/bin/bash
#                       /usr/local/bin/sync_bluehost-fay	
# https://crystalfaeries.net/posix/bin/sync_bluehost-fay	
# celeste:crystalfaery SYNC_BLUEHOST-FAY 2021-03-12 21:18:58+00:00
# rsync backup/mirroring script maps filesystem layouts between:
# BlueHost server box6537.bluehost.com, and
# "fay" (if i could set her hostname in TermUX), my Android.

# CONFIGURATION:
let SSHleep=10	# BLUEHOST RATE-LIMITS SSH CONNECTIONS :-(

echo ">=====>	box6537.bluehost.com	>=====>	fay.crystalfaeries.net	<=====<"	1>&2
echo "	  `now`"	1>&2
# collect updates to loose files at top level of server crystalfaeries.net
# some of which are updated periodically / automatically / frequently
rsync -auvH	\
	divservi@box6537.bluehost.com:~/crystalfaeries.net/{{.,}*.txt,*.html}	\
	~/crystalfaeries.net/
echo -n "SSHleeping	${SSHleep}: "	1>&2
	uptime	1>&2
	sleep	${SSHleep}	# BLUEHOST RATE-LIMITS SSH CONNECTIONS :-(
	echo "	  `now`"	1>&2

#	TOP LEVEL DIRECTORIES:
for target in	\
	celeste	\
	clairvoyance	\
	linkdoc	\
	posix	\
	src	\
	fae	\
	pdf	\
	audio	\
	video
do	# roughly size order for directories
	echo "========	${target}	========"	1>&2
	rsync	-auvH	\
--exclude=posix/bin	\
	divservi@box6537.bluehost.com:~/crystalfaeries.net/"${target}"/{.??,}* \
	~/crystalfaeries.net/"${target}"/
echo "-------	${target}	-------"	1>&2
echo -n "SSHleeping	${SSHleep}: "	1>&2
	uptime	1>&2
	sleep	${SSHleep}	# BLUEHOST RATE-LIMITS SSH CONNECTIONS :-(
	echo "	  `now`"	1>&2
done
# Backup scripts avoiding symlink vs directory
echo "========	POSIX/bin	========"	1>&2
rsync -auvH	\
divservi@box6537.bluehost.com:/home1/divservi/crystalfaeries.net/posix/bin/{.??,}* \
	~/crystalfaeries.net/posix/bin/
echo "-------	POSIX/bin	-------"	1>&2
echo -n "SSHleeping	${SSHleep}: "	1>&2
	uptime	1>&2
	sleep	${SSHleep}	# BLUEHOST RATE-LIMITS SSH CONNECTIONS :-(
	echo "	  `now`"	1>&2

# Grab the imgs (sans the igal2 thumbnails for web access)
echo "========	imgs	========"	1>&2
rsync	-auvH	\
--exclude='*/*/*.css'	\
--exclude='*/*/?.html'	\
--exclude='*/*/??.html'	\
--exclude='*/*/???.html'	\
--exclude='*/*/????.html'	\
--exclude='*/*/.indextemplate2.html'	\
--exclude='*/*/.slidetemplate2.html'	\
--exclude='*/*/.thumb_*'	\
--exclude='*/*/.tile.png'	\
--exclude='*/*.css'	\
--exclude='*/?.html'	\
--exclude='*/??.html'	\
--exclude='*/???.html'	\
--exclude='*/????.html'	\
--exclude='*/.indextemplate2.html'	\
--exclude='*/.slidetemplate2.html'	\
--exclude='*/.thumb_*'	\
--exclude='*/.tile.png'	\
--exclude='*.css'	\
--exclude='?.html'	\
--exclude='??.html'	\
--exclude='???.html'	\
--exclude='????.html'	\
--exclude='.indextemplate2.html'	\
--exclude='.slidetemplate2.html'	\
--exclude='.thumb_*'	\
--exclude='.tile.png'	\
 divservi@box6537.bluehost.com:~/crystalfaeries.net/imgs/{.??,}*	\
	~/crystalfaeries.net/imgs/
echo "-------	imgs	-------"	1>&2
echo -n "SSHleeping	${SSHleep}: "	1>&2
	uptime	1>&2
	sleep	${SSHleep}	# BLUEHOST RATE-LIMITS SSH CONNECTIONS :-(
	echo "	  `now`"	1>&2

# Fold the clipart (sans the igal2 thumbnails for web access) into imgs hierarchy
echo "========	clipart	========"	1>&2
rsync	-auvH	\
--exclude='*.css'	\
--exclude='?.html'	\
--exclude='??.html'	\
--exclude='???.html'	\
--exclude='????.html'	\
--exclude='.indextemplate2.html'	\
--exclude='.slidetemplate2.html'	\
--exclude='.thumb_*'	\
--exclude='.tile.png'	\
 divservi@box6537.bluehost.com:~/crystalfaeries.net/clipart/{.??,}*	\
	~/crystalfaeries.net/imgs/clipart/
echo "-------	clipart	-------"	1>&2
echo -n "SSHleeping	${SSHleep}: "	1>&2
	uptime	1>&2
	sleep	${SSHleep}	# BLUEHOST RATE-LIMITS SSH CONNECTIONS :-(
	echo "	  `now`"	1>&2

echo ">----->	box6537.bluehost.com	>----->	fay.crystalfaeries.net	<-----<"	1>&2
exit	$?

