This method does not allow you to roll back to previous dated backups like certain backup solutions do (Time Machine, for example). What it does is create a mirrored backup of your Mac on a remote server, so it's best used in conjunction with a local hard drive-based incremental backup solution. Still, if the house burns down, your files will be safe and once you've done the initial backup, rsync is very efficient at keeping your remote backup mirrored with your disk.
In this example, we're going to backup the currently logged-in user's Documents folder.
What you'll need:
- rsync running on your Mac (it's there on 10.4 and 10.5)
- An Internet Service Provider (ISP) who allows you to connect via SSH. Examples: 1 2 3.
- Set up the remote server
- You're going to need shell access to your server. If you don't already have it, and you use cPanel to administer your server, then there is often a 'Request Shell Access/Remote Login' option. If there isn't, contact your ISP directly.
- With shell access set up, create a folder that is outside of the scope of your webserver. You could use FTP to do this, if you prefer. For example, set up a folder called private_BKP at the root level of your server, and put a folder in there called Mac_One_BKP. The path is then /home/private_BKP/Mac_One_BKP, and it's in there that we're going to put the contents of our Documents folder.
- Set up your Mac
- Launch the Terminal application (found in your Utilities folder).
- Type the following:
rsync -avz -e ssh /Users/yourUserName/Documents yourLoginName@yourServer.com:'/home/private_BKP/Mac_One_BKP'An easy way to do the first part is to type rsync -avz -e ssh, then drag and drop your Documents folder right into the Terminal window. Watch out that your system does not add a slash (/) after the word Documents. If it does, just remove it. Why? The slash will tell rysnc to copy the contents of the Documents folder, rather than copying the whole folder.
- For the second part, you need to guarantee that yourLoginName@yourServer.com:'/home/private_BKP/Mac_One_BKP' is pointing to the folder you created on your remote server.
- Before starting the transfer, you may want to exclude certain files and folders from being sent to the server (very private stuff, caches, etc.) To do this, see the section below on Deletes and Excludes.
- Press Return, and you'll be asked for your password. Provide it, and you should see a long list of files scrolling in the Terminal window. These are the files moving from your machine to the remote server.
- If you want to check out what the -avz -e stuff does, take a look at the rsync man page.
- Your first backup can take hours, if not days (don't worry -- it'll be much faster the second time around, thanks to rsync's ability to transfer only the parts of files that have changed. Take a break from the computer and have a buy a real copy of this instead.
One you've backed up your Mac's Documents folder using the method above, there will come a time when you will want to run the script again -- like when you add new content to your folder! However, you many also have deleted some content from your Documents folder.
- To have rsync delete files on the remote server that are no longer on your machine, add --delete to the command: rsync -avz --delete -e ssh ...etc.
- To have rsync exclude the transfer of certain files to the remote server , add --exclude='myFileName' to the command: rsync -avz --delete --exclude='myFileName' -e ssh ....etc.. You can add multiple --exclude statements, or add a list via an --exclude_from file (see the manual).

