3. Setting up FileSystems and Snapshots (part 2)

March 24th, 2011

Note: This post is one in a series aimed to be a tutorial eventually, it’s not currently finalised and at the moment exists as a place for collating thought and collecting feedback

In part 1 of this blog post, I showed you how I created a script that would, when run, rotate your snapshots on a ZFS filesystem. For this to be usable, we need to create a mechanism for having it be automatically ran. We’ll do this with a cronjob.

On Unix systems, the cron daemon is used to execute scheduled commands. Picture it much like windows task scheduler for all you windows kiddies.

I saved the backup script we wrote yesterday to /FileStore/backups.sh. The first thing I want to get running is my hourly backups. To do this, we’ll start editing our cron file

sudo crontab -e

The crontab utility is a program used to edit the tables that drive the cron daemon.

On my OSX box, information about how to set up the cron file can be found in ‘man 5 crontab’

Basically, cron examines cron entries once every minute. the fields that we’ve got to play with are (in this order)

field allowed values
—– ————–
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

Having said that, it’s time to think about when we want to create our snapshots. Because I intend machines to do their backups to the server on the hour, I’ll be creating my snapshots at half past the hour. My cron file now looks like this (for hourly snapshots with 24 rotations, daily snapshots with 7 rotations, Weekly snapshots with 4 rotations.

#**Snapshots for the Filesystem**
30 * * * * /bin/bash /FileSystem/backups.sh hourly 24
30 6 * * * /bin/bash /FileSystem/backups.sh daily 7
30 6 * * sun /bin/bash /FileSystem/backups.sh weekly 4

Now that that concludes our section on setting up my rotating snapshots.

Other posts to come in the series:
1. Selecting the hardware
2. Installing the Operating System
3. Setting up File systems & Snapshots
4. Allowing access through NFS & SAMBA
5. Setting up encrypted off-site backups
6. Configuring Windows & Linux clients to dump backup info to the FileServer
7. My router setup, configuring IP tables & torrents on a low-powered server.


Leave a comment