Backup Your Mac to Hidden Location With Rsync


This remaining weekend I nearly lost all of the pictures. We have four children, and feature heaps of pix. I had set up the user money owed on our Mac on an external mirrored drive, related by Firewire. This was in the main good, however this weekend all the applications simply refused to attach because of a few sort of weird permissions issue. I went through all forms of stuff to get it working, however on the end of the day I just created a brand new account and copied all of the files over to internal drive on the Mac, then modified the ownership of all the documents, and idea I become properly to go.

That become until my spouse went to make a Christmas ebook for her grandmother. Some of the photos had been missing, and all were blurry. The full sized photographs have been long gone. I ended up having to restore everything from Time Machine, which is right for the one’s styles of things, so the whole thing turned out ok. But I have always been worried about what might occur if the Mac and the linked drives had been stolen. I may want to use a web backup service… But I don’t want to do this. There needed to be a higher way.

I observed that you may use the UNIX application sync to create a little script that could return up every document to a remote sync server. I did not have one of those, but I did have a USB power connected to my home wi-fi router, so I figured I may want to set is up to duplicate the files to that. No cross. Rsync does not work thoroughly connecting to a samba server on the alternative give up. I needed to set up a real sync server.


There become a vintage PC in the basement that I had installation a duplicate of Ubuntu Linux on the last yr. Setting up Ubuntu is ridiculously easy, mainly on a PC that may be a few years antique. Just go to ubuntu.Com, download the contemporary replica, put it on a USB stick, and boot to it. It sets up the entirety routinely.

As I researched this, I discovered out I could very effortlessly set up a rsync server on the Linux box and duplicate over documents from the Mac, but it changed into too clean. It was too clean due to the fact rsync is not cozy. All the files were sent over my wi-fi unencrypted. I do not like doing things unencrypted, no longer protected by passwords. When safety is so clean to add into a gadget, it is worth taking some greater minutes to do things properly.

What I determined to become that you could installation rsync to perform over at ease shell (ssh), that’s encrypted. Furthermore, there is a function built into ssh that permits trusted computers to login without having to apply a username or password by means of using public/private key encryption. So this is what I installation. There is a simple line script I placed on the Mac that I set to run as soon as per week, and it copies over just the modified files from the Mac to the Linux field hidden within the basement. I actually have moved over to an 802.11n system, so the wireless runs best and speedy, properly for shifting all the ones gymnastics pix and videos.

So, the procedure is as follows:

Give your Linux field a static IP deal with so that you can ssh to it. If you are fancy, supply it a call to your internal DNS server. I am not that fancy.

Set up the Mac in an effort to ssh to the Linux container with signatures by using generating a key pair, doing a cozy replica to the non-root user account at the Linux field (name it backup user or something like that), and placing it in the depended on keys record. See this internet site on ssh-keygen Mac to look how it is achieved.

Make a listing at the Linux box to keep the backup files. I store mine on the outside USB drive, so I created a directory called /media/Volume/USBdrive/mac_backup and gave the ownership of the listing to the backup user at the Linux box.

After you try this, you want to make certain that the USB power mounts while the Linux field is rebooted. Mine did not, so I needed to make an entry inside the /and many others/fab report to ensure it hooked up on boot.

Create a rsyncd.Conf record in the /domestic/backup user listing. This is the intricate component – do not configure the principle container’s rsync server or its rsync.Conf file. This is going to be a mini-rsync server this is kicked off when the Mac does an ssh to the backup user account on the Linux container. Here is what the rsyncd.Conf file must appear to be:

path = /media/Volume/mac_backup

examine handiest = false

use chroot = false
Then create the script in a text report at the Mac and name it something like rsync_backup_script.Txt. It needs to include something like this (the is for in which I needed to fit it onto this web page, do not actually type the and do put the entirety at the identical line. Also replacement @ for (at the person)):

rsync -av –delete –exclude ‘.DS_Store’ –rsh=”ssh -l backup user”

/Users/ backup user(at character)192.168.5.Five::mac_backup
The rsync command copies any new or modified documents from the Mac to the Linux container. It also deletes any documents at the backup which have been deleted at the Mac.

Make the script executable. There is some manner to do that with the GUI, however, I just open the terminal at the Mac, navigate to the directory with the record, and kind:
do mod u+x rsync_backup_script.Txt
Now check the whole lot! You should just move to it and execute the script through coming into on the command line:
If that does not paintings you then need to step thru the parts of the manner – ensure you may ssh without using a password, take a look at the file permissions on the Linux box, check the rsyncd.Conf report, and even input the command at the Mac terminal line via itself to make sure the entirety works.


It will take hours for the primary backup if your device is whatever like mine. The script is an installation to compress any documents it could, and in destiny backups, it’s going to handiest switch the adjustments.
This isn’t constrained to backing up Mac’s. You can do the equal issue with Windows containers by using installing Cygwin on the Windows machine and going thru a comparable technique. Just create every other listing at the backup power, create a 2nd profile in the rsyncd.Conf record that makes use of an exclusive profile call and points to the brand new pressure location, and you are off and walking.

If you do have to use your backup, you may use the alternative command to duplicate the files lower back to the Mac. Hopefully, you won’t try this, although! Something like this need to work:



rsync -av –rsh=”ssh -l backup user” backup user(at person)192.168.Five.5::mac_backup /Users/
That is the entire workout. I have long past through the documents at the Linux container and made certain they’re there, so I am satisfied. The field has no display screen or keyboard related to it, and it seems like a chunky vintage PC that no person desires. The noisy 1TB reflected difficult drives within the external array are a little noisy, that is some other accurate motive to preserve it hidden away.

Of route I nonetheless make a USB replica each sometimes and take it to work, however, this is the backup to the backup to the backup. Hopefully, I will have properly copies of my documents to be had for many years to come back.