Remote backup to encrypted disk image with rsync

This presumes you have access to an OS X host running sshd, and that you have already configured passphrase-less ssh keys to login to the remote host.

Onto a script. This is an example:

#!/bin/bash

#set your password
ENCRYPTION_PASS='mypassword'

#Mount the encrypted disk image on the remote system
ssh -i ~username/.ssh/id_dsa username@remotehost.com "/bin/echo -n $ENCRYPTION_PASS | hdiutil attach -stdinpass -readwrite -mountpoint /Users/username/private/ /Users/username/encrypted.dmg.sparsebundle" >> backup.log 2>&1

#rate limited rsync if desired
#rsync --rsh="ssh -i ~username/.ssh/id_dsa" --delete -a --progress --bwlimit=1000 --exclude ".AppleDouble" --exclude ".DS_Store" /c/media/Pictures username@remotehost.com:/Users/username/private/ >> backup.log 2>&1

#not rate limited
rsync -e "ssh -i ~username/.ssh/id_dsa"  --delete --progress -a --exclude ".AppleDouble" --exclude ".DS_Store" /c/media/Pictures username@remotehost.com:/Users/username/private/ >> backup.log 2>&1

#unmount the remote disk image
ssh -i ~username/.ssh/id_dsa username@remotehost.com hdiutil detach /Users/username/private/ >> backup.log 2>&1

#move the log to a log with a date stamp
mv backup.log backup.`date +"%Y_%d_%m_%H_%M"`.log