RSync from remote internal server
#!/bin/sh
# Access via SSH tunnel using local LHOST:LPORT
LPORT=2201
LHOST=127.0.0.1
# Access remote system via internet facing EUSER@EHOST to internal IUSER@IHOST
# Note: Local SSH pub key must be installed in target IHOST authorized_keys file
EUSER=peter
EHOST=ideell.se
IUSER=share
IHOST=cube
# Setup SSH tunnel:
ssh -f -N -M -S /tmp/hg-tunnel -L $LPORT:$IHOST:22 $EUSER@$EHOST 2>/dev/null
# Test SSH
# ssh -p"$LPORT" $IUSER@$LHOST ls
# Test rsync
FOLDER="books/Math"
FROM=$IUSER@$LHOST:$FOLDER
TO=/home/peter/rsync-test/backup
FLAGS="-a --delete -ai --progress"
/usr/local/bin/rsync -e 'ssh -p 2201' $FLAGS $FROM $TO
# Exit SSH tunnel
ssh -S /tmp/hg-tunnel -O exit $EUSER@$EHOST