rsync is a very efficient and secure means of copying / mirroring a set of files between two different servers.
Here is an example of how to mirror the contents of a directory on a remote machine to the local machine:
rsync -avz --delete -e ssh email@example.com:/full/path/ /var/www/directoryname/
With just a little bit of simple scripting it is easy to add an system of hard-linked (storage efficient) rotating daily incremental backups to your rsync backup strategy.
For instance, say I wish to backup a directory /home/user/data on my local server or hosting account to another hosting account, in this example nearlyfreespeech.net. This is the script I run on my local server:
ssh firstname.lastname@example.org "/home/protected/data/rotate.sh"
rsync -avz --delete -e ssh /home/user/data email@example.com:/home/protected/
The first line executes a script on the REMOTE SERVER which first rotates the backup sets. Then the second line uses rsync to push the current state of the directory from the local server to the remote server. The "rotate.sh" script executed in the first line above is also in the directory being backed up, and contains the following:
rm -rf /home/protected/data.5 mv /home/protected/data.4 /home/protected/data.5 mv /home/protected/data.3 /home/protected/data.4 mv /home/protected/data.2 /home/protected/data.3 mv /home/protected/data.1 /home/protected/data.2 cp -al /home/protected/data /home/protected/data.1
The key component is probably "cp -al", which makes a full archival copy of the current directory /home/protected/data to the first incremental backup using HARDLINKS. This makes the whole process very storage efficient (and therefore cheap on nearlyfreespeech.net, which charges for storage by the Megabyte) as there is only one copy of the contents of any file kept in the backup setup. All identical files are hardlinks to this copy.