Rockstor and Mac

With Rockstor’s recent addition of support for AFP, its quite easy to use it for Time Machine backups from Mac

I’ve been using it for my Time Machine backups from my Macbooks, and things have been running fairly smoothly.

To setup Time Machine backups to Rockstor, you have to configure a Rockstor share for Time Machine backups, and then set that share as the Time Machine disk in the TIme Machine preferences. Here are the steps to do that.

Rockstor setup for Time Machine backup (Steps to follow on Rockstor Web-UI)

Start the AFP service. Login to the Rockstor Web-UI and make sure the AFP service is started (System -> Services).

Create a share for Time Machine backups. From the Rockstor webui, create a share that you will use as your Time Machine backup disk. (Name the share with an easily identifiable name since Time Machine will see that name in the list of available disks when you configure Time Machine). Make sure that the share is large enough to hold your entire Time Machine backup.

Create a user for Time Machine to connect as. Create a Rockstor user that Time Machine will be accessing the share as, and change the ownership of your share to that user.

Export the share through AFP. Navigate to the AFP menu section and export your destination share through AFP. Select ‘yes’ for the ‘Time Machine’ option. The image below shows how I export my share, called ‘TimeMachineDisk’ through AFP.

Time Machine setup (Steps to follow on your mac)

Enable Network Volume support for Time Machine. On your Mac machine, you will first have to enable Time Machine to support network volumes. In your terminal, enter the following command

Set the Time Machine disk. Next, set the Rockstor share as the Time Machine disk. To do this, open the Time Machine preferences, and click ‘Select disk’. You should be able to see the Rockstor share that you created above, in the list of available disks. Select it as your Time Machine disk. In the image below, you can see that Time Machine shows the ‘TimeMachineDisk’ share that I created above as one of the available disks.

Connect as the Rockstor user. When you select the disk above, Time Machine will popup an authentication dialog asking for a username and password. Enter the username and password of the Rockstor user that your created above(Don’t forget that in addition to creating the user, you need to change the Share’s ownership to that user). Time Machine should be able to connect to the disk. If not, go back and check your username and password, and the Rockstor configuration steps above.

The setup is now complete. On the next backup, Time machine will prepare and then use your Rockstor share as its backup disk.

The following tips are not specific to Rockstor, but general information that I’ve found useful while using Time Machine:

First time backups: The first time you backup data using Time Machine, it has to copy all the data to the disk, so it is preferable to do it over a wired connection. I’ve experienced much better speeds using a wired connection than WiFi.

Incremental backups: Once Time Machine has made its first backup, it only copies the differences since the last backup on subsequent backups, so these should be much faster, assuming you’re backing up fairly frequently.

On a Mac, you can use Time Machine to maintain backups of your hard drive, with versions, so that you can jump back to any point in time that Time Machine has made a backup. But what if you wanted to do that only for a few folders, and with more control over the whole process? This post describes how to achieve this using rsync and the snapshot feature of RockStor.

Versions of backup folders using rsync

This post was inspired by Time Machine for every Unix out there, which uses the –link-dest option of rsync to maintain links to older versions of files. With RockStor, we can achieve the same thing with snapshots, which are an efficient way of capturing the state of a folder at a specific point in time.

A better way. rsync + Snapshots = Versioned Backup

Here’s how I take backups of a folder on my Mac, to a shared folder on RockStor, and maintain versions of this folder. (See the earlier blog post to make a RockStor Share accessible as a shared folder on your Mac).

Every time I want to make a backup, I do the following

Copy files using rsync

Using rsync, I copy the Mac folder to the shared folder. The first time, this operation could take a long time since it copies the entire folder contents over. But the subsequent ones will be faster since only the changes from the previous time will be copied.

rsync -avz <source_folder> <shared_folder>

Take a snapshot of the share

A snapshot is a point in time representation of the contents of the Share. RockStor allows users to take snapshots of shares using either the web-ui or the command line interface (CLI). Since I like to automate my backup process, I use the CLI over ssh to issue a snapshot command for that share. (In my script I generate a snapshot name that contains the current date and time, so that I can identify the snapshot folders easily). The command to create a snapshot with the name ‘mysnapshot’ for the share ‘myshare’ is as follows.

The snapshot command is issued over ssh. The CLI works as a series of subsystems, and you navigate to the subsystem you desire and issue the appropriate command. Here’s what the different components of the command mean

shares – this takes you to the ‘shares’ subsystem

share myshare – takes you to the subsystem for operations on the share ‘myshare’

snapshot add -v mysnapshot is the command to add a snapshot with name ‘mysnapshot’ for the share. The -v flag makes the snapshot visible as a hidden folder in the Samba export.

This way I have a list of snapshots, at multiple points in time, so I can go back and retrieve files from an older snapshot, if I accidentally lose anything in my current folder on the Mac.

Let see an example of retrieving a file from a snapshot, when it has been deleted from the share.

In my folder share2, I have a few image files, which you can see in the screenshot below. At this point, I have not created any snapshots.

I now take a snapshot of the share, and the snapshot appears as a hidden folder in the share. The snapshot contains all the files that were in the share at the time the snapshot was taken, as seen below.

Now I delete the file called ‘ocean_bean_1.jpg’, and as you can see from the screenshot below, it is not present in the share itself, but is still present in the snapshot. So If I need to retrieve it at any later point in time, I can always get it from that snapshot folder.

Snapshots thus are an easy and efficient way to maintain versions of folders, and enable you to retrieve files, or versions of files that were present at some point in the past.