Sat, 15 Jan 2005

trivial but useful hack for redirecting rsync through a firewall

rsync is an excellent tool for replicating directory trees on a drive or across a network. You can specify the transport layer for network copies, it defaulting to use ssh. The below script just pipelines two sshs together cleanly to use as a the transport, to replicate a directory tree to/from a server inside a firewall:

example command line from outside the firewall:

ENDHOST= rsync --delete  -vzaP --rsh ./ /backup/fubar/
In this case ENDHOST is set to the IP address of the endpoint host inside the firewall, while is the hostname of the firewall we have ssh access to to get to the firewall. consists of the following

# simple ssh wrapper so we can treat 2 sshs pipelining as one..
shift 1
exec ssh $MIDHOST ssh $ENDHOST $*
Nice and simple, and saves a lot of messing about with port forwarding, escaping of command line args etc.

Posted at: 21:59 | category: /nerdy | # | 0 comments