My Backup Strategy

Now that a new year is here I really need to finish some points of my To-Do list! Here we go… As I said few weeks ago, maybe a little bit delayed, here comes how I backup all my stuff. This post is not a how-to. It’s just a configuration example. If you want a howto use this link.

Some theory I have a central fileserver, some application servers (Web, Mail, MySQL) and a few workstations (Mac, Win, Linux). All I want is a simple way to backup databases, mails, configs and of course documents on my fileserver to an external harddisk. But there is no do-it-all tool. There are many small and some bigger tools to do what I want. Some of them look unmaintained, some of them are hard to setup and some… ah let’s say I didn’t like them The two lists at debianhelp.co.uk (list1, list2) were very helpful to me.

For me it all came down to two tools: Backuppc and Rsnapshot. Backuppc is a big tool. It’s designed for large networks with serveral Workstations. Besides Rsync over SSH it does support backing up Windows machines natively over SMB and has a (in my eyes pretty ugly and unclear) WebInterface to manage your backup jobs… I haven’t managed to setup a single backup job in 30 minutes through the Webinterface, but I didn’t RTFM though. Backuppc has some nice features that Rsnapshot is lacking: compressing, nice restore options, reminders… Rsnapshot is more closely to the “one job one tool” philospohy of UNIX. It uses Rsync over SSH. You can also use Rsnapshot to backup your Windows machines, but you’ll have to install cwRsync on every Windows machine. Setup is (in my eyes) very easy… just modify the well documented rsnapshot.conf to your needs and let rsnapshot run via cron.

My Backup strategy I choose rsnapshot to backup at least my documents and configs (time will show how well it performs for maildir) and AutoMySQLBackup for (guess what?) MySQL. Since configuration is that easy I’ll  just show my snippets from rsnapshot.conf

Configs, Documents & Stuff on the machine rsnapshot runs on:

1
2
3
4
5
6
backup /home/ fry/
backup /etc/ fry/
backup /var/www/ fry/
backup /srv/data/photos/ fry/
backup /srv/data/music/             fry/
backup /srv/data/documents/ fry/
The Webserver (via SSH):
1
2
3
backup root@leela:/etc/ fry/
backup root@leela:/home/ fry/
backup root@leela:/srv/data fry/
I think you got the idea. Just read the comments if you didn’t. Finally my full rsnapshot.conf:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
snapshot_root /srv/backup/hosts/
no_create_root 1
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
interval daily 7
interval weekly 4
interval monthly 3
verbose 2
loglevel 3
logfile /var/log/rsnapshot
lockfile /var/run/rsnapshot.pid

# LOCALHOST
backup /home/ fry/
backup /etc/ fry/
backup /var/www/ fry/
backup /srv/data/photos/ fry/
backup /srv/data/music/ fry/
backup /srv/data/documents/ fry/

# BENDER (MySQL)
backup root@bender:/etc/ bender/

# LEELA (Web)
backup root@leela:/etc/ leela/
backup root@leela:/home/ leela/
backup root@leela:/var/www/ leela/

# AMY (Mail)
backup root@amy:/etc/ amy/
backup root@amy:/home/ amy/
backup root@amy:/var/bogofilter/ amy/
backup root@amy:/var/mail/ amy/

# ZOIDBERG (Relay1)
backup root@zoidberg:/etc/ zoidberg/
backup root@zoidberg:/home/ zoidberg/

# FARNSWORTH (Relay2)
backup root@farnsworth:/etc/ farnsworth/
backup root@farnsworth:/home/ farnsworth/i
That said about documents and mails backup. Please also read the comments in rsnapshot.conf, the official HowTo and the manual. I already wrote a post about MySQL backup. It’s configuration is as easy as:
1
2
3
4
5
6
USERNAME=yourmysqlbackupuser
PASSWORD=keepitverysecret
DBHOST=yourmysqlserver's hostname
DBNAMES=all
BACKUPDIR=/path/on/your/backupserver
MAILADDR=you@example.org
I backup to a 500Gb WesternDigital HDD in an external case which I mount on demand. Since the case has it’s own PSU that gives me at least a little security from power peaks (a dying PSU already killed my motherboard and harddisk a few years ago) or scripts running amok or accidently deletion…

Now that you know how I backup, it’s time to read a bit about restoring. Fortunately with rsnapshot it’s as easy as copying the relevant files/directories from the backup to it’s origin through commandline (use cp or maybe rsync), midnight commander or whatever you want…