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 refused to attach because of a few weird permissions issues. 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 the 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 might use the UNIX application sync to create a little script that could return 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 might want to set it up to duplicate the files to that. No cross. Rsync does not work thoroughly; connecting to a samba server on the alternative gives 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 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 sync server on the Linux box and duplicate 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 wouldn’t say I like doing things unencrypted, no longer protected by passwords. When safety is so clean to add to a gadget, it is worth taking some greater minutes to do things properly.

I determined to become that you could make installation rsync to perform over at ease shell (ssh), that’s encrypted. Furthermore, a function is built into ssh that permits trusted computers to log in without applying a username or password using public/private key encryption. So this is what I installation. I placed a simple line script 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 shifting all the 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 to ssh to the Linux container with signatures by using a key pair, making 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 at 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/USB drive/mac_backup and gave 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 enter the /, and many others/fab reports 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 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 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 move to it and execute the script through coming into on the command line:
If that does not paintings, you need to step through the parts of the manner – ensure you may ssh without using a password, take a look at the file permissions on the Linux box, and check the rsyncd.Conf report, and even input the command at the Mac terminal line via itself to ensure 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 installing Cygwin on the Windows machine and going through a comparable technique. Just create every other listing at the backup power, create a 2nd profile in the rsyncd. Conf record that uses 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(a person)192.168.Five.5::mac_backup /Users/
That is the entire workout. I have long passed through the Linux container documents 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 copies of my documents properly for many years to come back.

Jeffery D. Silvers
Love and share my articles, I will be happy to react on it ! Spent 2002-2009 promoting weed whackers in Edison, NJ. Earned praise for importing junk food for fun and profit. Spent 2001-2006 exporting teddy bears in Atlantic City, NJ. Had some great experience investing in tattoos in Fort Walton Beach, FL. Spent 2002-2007 selling action figures in the aftermarket. Enthusiastic about working on basketballs on the black market.