The Robservatory

Robservations on everything…

 

Create Time Machine-like backups via rsync

Taking a break from the recent Frankenmac posts, here’s a little trick for creating “Time Machine like” backups of anything you’d care to back up1I don’t know how well this might work for Mac files, as opposed to Unix files. But Mac files can be saved to the real Time Machine.. In my case, it’s the HTML files off of my web sites, both personal and work. I used to simply back these up, but then realized it’d be better to have versions rather than totally overwriting the backup each day (which is what I had been doing).

Once you’ve got it set up and working, you’ll have a folder structure similar to the one at right, with one folder for each backup, and a “current” link that takes you to the newest backup.

I get zero credit for this one; my buddy James explained that he’d been using this method for a year without any troubles, and pointed me to this great guide that explains the process.

I used that guide and added the following to my backup script to create my own customized Time Machine for the files from here, robservatory.com:

/usr/local/bin/rsync -aP \
  --link-dest=/path/to/quasi/TM_backup/current user@host:/path/to/files/on/server/ \
  --exclude "errors.csv" \
  --delete --delete-excluded \
  /path/to/quasi/TM_backup/back-$newtime
rm -f /path/to/quasi/TM_backup/current
ln -s /path/to/quasi/TM_backup/back-$newtime /path/to/quasi/TM_backup/current

And that’s all there is to it. Note that you may need a newer version of rsync than what comes with macOS now (2.6.9)—I use version 3.1.2 from Homebrew, so I can’t say for sure that this script works with the stock version.

I’ve only been using this for a couple weeks, but it’s working well for me so far.

4 Comments

Add a Comment
  1. I am not sure you need or even want –delete since you want snapshots *as they were*. I am not sure if it would delete on the older backup or do nothing at all.

    I wrote a Python wrapper around this rsync call to automatically delete older snapshots and do some other exclusions. I will post it to github eventually and pass it on

  2. I’m currently testing this with a few modifications tailored to my environment. Thanks for finding the time and posting it here!!

    I have a doubt though. I wonder if the global behaviour matches what time machine does, meaning that every snapshot that TM creates I think has symbolic links to the previous backup, thus sparing a lot of space. My feeling at this point (and I reiterate that I’m currently testing this) is that every back-$newtime folder will only contain the “delta”, but it will not be self-contained in itself, will it? Not sure I’m making my point correctly…

    1. No, they’re full backups—I have a complete copy of all the files in each backup. It’s done with hard links, I believe, so it doesn’t take up a ton of space.

      -rob.

Leave a Reply

The Robservatory © 2017 Built from the Frontier theme