rsync Setup for Mac OS X - Home directory only
xxx.xxx.xxx.xxx is the IP address of the backup server
This page is for the Macintosh client. "Client" is the computer being backed up by the server.
1. Generate SSH keys
We will call the name of the user 'linus.' So every time you see 'linus', replace it with your own username. First, in your home directory, as the linus user,
ssh-keygen -t rsa
It will ask for where to store the file and passphrase. Do not enter anything and just keep pressing enter. Now let's make a copy of the public key for the server.
cd ~/.ssh
ls
The above is to make sure you have id_rsa & id_rsa.pub
cp id_rsa.pub clientname_id_rsa.pub
clientname is the name of your computer (which appears in your terminal; eg linus@linusbox:~$ - in this case linusbox is your computer name). I am assuming that you have a unique computer name on your network. The private key file (id_rsa) is something that you must guard with your life! (ok i'm exaggerating) Let's make sure that it's non-readable by anyone else but linus;
chown linus:linus id_rsa
chmod 600 id_rsa
2. Exchange SSH keys with Server
Email 'clientname_id_rsa.pub' to the administrator so that they can put it in the server's .ssh directory.
To allow the server access to your computer, obtain the public SSH key of the server from the administrator.
Once you have the server public key (BackupPC_id_rsa.pub), you must add it to the authorized key list. If you already have a file named 'authorized_keys2' in your /home/linus/.ssh directory, you can skip the third command.
cd /home/linus/.ssh/
touch authorized_keys2
mv /location/of/the/file/BackupPC_id_rsa.pub /home/linus/.ssh/
cat BackupPC_id_rsa.pub >> authorized_keys2
/location/of/the/file/ is obviously where you downloaded and placed the file. Now for additional security, we want to limit the allowed host to the backup server. Note that I use the text editor gedit, but you can use vi, nano, kate, or anything else.
If you use vi for the first time, click here for more information.
gedit /home/linus/.ssh/authorized_keys2
Add the address of the server at the beginning of the file to make the file look like this: (bolded part)
from="xxx.xxx.xxx.xxx" ssh-rsa [base64 key, eg: ABwBCEAIIALyoqa8....]
Make sure again the permission is set correctly.
chmod -R go-rwx /home/linus/.ssh
3. Create Config File
Now in your home directory as the regular user, create your configuration file named 'clientname.pl' where clientname is the name of your computer.
gedit clientname.pl
Copy and paste the following.
$Conf{XferMethod} = 'rsync';
$Conf{BackupFilesExclude} = [.Trash', '/Trash', '/automount', '/Network', '/private/var/automount', '/private/var/run', '/private/var/vm', '/private/var/tmp', '/private/tmp', 'Caches', 'CachedMessages', '/stuff/unwanted'];
$Conf{ClientNameAlias} = 'xxx.xxx.xxx.xxx';
This file assumes that you want to back up everything in your harddrive except for the directories specified in the config file. To add more directories to be excluded, simple add the paths to the directories in the second line following the syntax shown above (ie wrap the path with '' and have a comma and a space in between).
If you wish to back up only the specified files, then replace the second line with the following and likewise add desired directory paths to that line following the syntax.
$Conf{BackupFilesOnly} = ['/myFiles', '/important', '/home/linus/stuff'];
If you wish to add more options (otherwise the default settings will be used), please refer to the BackupPC documentation website.4. Submit Files to Administrator
Now let us send the following files and information to the administrator (by email or whatever) if you have not dones so already.
- clientname_id_rsa.pub
- clientname.pl
- Your username (in our case it is linus).
At this point, the administrator should get back to you with your own username and password (which they might ask you to come up with) and the good news that your back up service is up and running.
5. Turn On SSH Server
In Mac OS X, SSH is installed by default, but the server part of it is not turned on. To turn it on, click on the beloved apple --> System Preference --> Sharing. You should see a screen like the one below.
Click on 'Remote Login' under services and close the window.
6. Connect & Back-up!
After you have heard back from the administrator, do the following to connect.
Bookmark the address below and go to it;
http://xxx.xxx.xxx.xxx/backuppc
Now a pop-up window will ask you for the username and password. These are the ones
the administrator gave you.
You should see something similar to below:
Click on 'Start Full Backup' button to start your first backup. Note that this
first backup will take a while. The next time you back up, it will be an 'incremental' backup
and should only take a few minutes.
If you get any error messages, let the administrator know of that message
7. Retrieve backed-up data
To restore files / folders, simply click on 'browse backups' link on the left menu.
You should see a screen like the above.
Then click the checkboxes next to the files and folders you want to restore and click on 'restore selected files.'
Once you click on 'restore selected files,' a screen like the below should show up. There are 3 options to what to do with the files / folders you've selected.
- Option 1: Direct Restore
- Option 2: Download Zip archive
- Option 3: Download Tar archive
Option 1 will write the backed up files / folders to your harddrive (if the same file is there, it will overwrite).
Option 2 and 3 will archive the files / folders and let you download the archived package as .zip or .tar respectively. This feature has other potential uses than just backup / restoration; you can access the backed up files / folders from anywhere in the world!
To do a complete system restoration, follow the same direction as above for all files & folders through KNOPPIX or something equivalent.
BackupPC Manual Start Page
Printer Friendly
October 13th, 2009 at 11:05 am
Can you, in more detail, explain what goes on on the Linux host? I’ve got my ssh keys created, but I’m not sure what to do with the keys on the Linux side of things.
Thanks for the great writeup!