In my previous article, I presented Amanda, its basic concepts, and how does it compare to Time Machine. Now, I’ll give you an example of how to install and configure a Mac OS X machine to be an Amanda client. The next post will explain how to properly recover after a catastrophic failure.
As with any UNIX tool, Amanda can be compiled, installed and configured in a lot of different ways. How you should do it depends on your needs, so don’t feel pressured to do everything in the same way I did, as it’s not “the right way”, just one way. Also, everything I describe here should work on the Leopard or Snow Leopard versions of either Mac OS X or Mac OS X Server on Intel or PowerPC Macs. I’m not sure about previous versions of the OS, but you may find more information about those in the Mac OS X installation notes page of the Amanda wiki.
Also, I won’t write anything here about installing an Amanda server. I’m assuming either you already know how to do it and just want to check how to backup Mac OS X clients, or that you are new to Amanda and will follow the appropriate tutorials and do some experimentation before moving Amanda to production.
Before installing Amanda on a client, you need to decide what you want to backup, and how to split that into Amanda “disks”. I usually backup the entire machine (a single Mac OS X volume), so the obvious choice to make would be to consider the root of the file system as the only Amanda disk. But I recommend you to not do that. Why? Two reasons:
- If you consider the entire Mac OS X volume to be a single disk, a level 0 backup will use a lot of space, and take a long time to complete. Even worse, if the space needed for a level 0 backup is as large, or larger, than a single tape, you may not be able to perform the backup at all. By splitting the volume into smaller disks, Amanda will spread level 0 backups of those disks over time, which will also spread the space and time used for those necessary level 0 backups.
- Different parts of your Mac OS X volume have different usage patterns. The /System directory, for instance, contains mostly read-only files that change only when installing a system update, which is a relatively rare event. On the other hand, the /Users folder contains user home directories, whose contents may change on a daily basis. This different behaviors lead Amanda to optimize it’s planning, specifically the decision to maintain of increase the backup level of a given disk, as explained in the previous article. If you don’t split two main directories like these, with radically different usage patterns, in different disks, you are making it harder for Amanda to make the right decision.
The way I split an OS X volume into several disks depends on what machine is used for. However, I end up doing it always the same way for normal use desktop machines. I create the following disks:
/ /Applications /Library /Users
This usually works fine. Note that, if you are not careful, by considering / (the root) a disk, you’ll include all the other disks (those directories are inside the root) and any other devices (hard drives, CD-ROMs, USB pens, etc) that may be plugged in that computer (they will be mounted into the /Volumes directory). I was told Amanda won’t include mountpoints (which means it would not backup anything inside /Volumes anyway) but I haven’t tested. We’ll see how to solve this issue shortly.
If your users home dirs contain a lot of data, or data that don’t need to be backed up, you may consider splitting the /Users directory into smaller disks, and excluding easily restorable directories, like ~/Music. I never had to split the /Users directory, but I do exclude the ~/Music directories and any directories that contain virtual machine hard drive images (like Parallels or VMWare). Those files are huge, and change every time an user launches their virtualization software. If your users don’t have important data on those virtual hard drives (like in my case, we only use Windows to run IE), you can easily re-install Windows from scratch. If you do have important data on those drives, I recommend you install backup software on the virtualized OS to keep that data safe.
Ok, enough talking, let’s do it.
1. Install a recent version of Xcode. You’ll need it to compile the needed stuff. Xcode 3.2.3 is the most recent version at the time I’m writing this and will do just fine.
2. Install MacPorts. Amanda needs glib2 to compile. glib2 has a lot of dependencies, so the easiest way to install it is using MacPorts. To do that, simply open the MacPorts installation page, download and run the appropriate installer for your version of OS X.
3. Install glib2. After having installed MacPorts, this can be achieved using one simple command (run it as superuser):
/opt/local/bin/port install glib2
All glib2 dependencies (and glib2 itself) will be downloaded, compiled and installed. This will take a while, specially on PowerPC Macs, so if you need to have a snack or refill your coffee mug, this is a good time to do it.
4. Create a user for Amanda and add it to the admin group. The best way to achieve this is to run the following list of commands as superuser:
sudo dscl localhost -create /Local/Default/Users/amandabackup sudo dscl localhost -create /Local/Default/Users/amandabackup RecordName amandabackup sudo dscl localhost -create /Local/Default/Users/amandabackup UserShell /bin/bash sudo dscl localhost -create /Local/Default/Users/amandabackup RealName "Backup User" sudo dscl localhost -create /Local/Default/Users/amandabackup UniqueID 5000 sudo dscl localhost -create /Local/Default/Users/amandabackup PrimaryGroupID 0 sudo dscl localhost -append /Local/Default/Groups/admin GroupMembership amandabackup sudo dscl localhost -create /Local/Default/Users/amandabackup NFSHomeDirectory /Users/amandabackup sudo ditto -rsrcFork '/System/Library/User Template/English.lproj/' /Users/amandabackup sudo sh -c "echo 'amandabackup_server.example.com amandabackup' > /Users/amandabackup/.amandahosts" sudo chmod 600 /Users/amandabackup/.amandahosts sudo chown -R amandabackup:wheel /Users/amandabackup sudo passwd amandabackup
The last command defines a password for amandabackup user. You can later configure your ssh deamon to accept only public key authentication.
5. Download Amanda. You may obtain Amanda’s source code from the Amanda downloads page. Although the 3.* versions are already available, I’m using 2.6.1p2 for now. This instructions assume you’ll be using the same version. I’m not sure if version 3 compiles well on OS X. After downloading, uncompress the file.
6. Compile and install Amanda. Amanda is installed using the standard UNIX configure/make/make install commands. You have, however, to provide some information on the configure command. The one I use is:
./configure --with-user=amandabackup --with-group=admin --with-ssh-security --without-server
After that, just run the usual:
make sudo make install
7. Create the /usr/local/var/amanda directory with the appropriate ownership. The install procedure somehow fails to create this directory, so you need to create it manually and give it the right ownership. So, as superuser, run the following commands:
mkdir -p /usr/local/var/amanda chown amandabackup /usr/local/var/amanda
Amanda is now installed on the client. If you are going to use ssh as the tunnel for your connection, you should now copy the server’s ssh public key to the client and test the connection. You can then add the client’s volumes to the disklist and run amcheck to test the configuration.
Now you need to add exclude files to make sure the root volume won’t contain all the others, and to exclude large files whose backup is not needed (like music or movies). To do that, you have to add a configuration directive in your Amanda server configuration files. That directive tells Amanda the name of the file that includes the exclude list, which is the list of files to be excluded from backup. This is a sample configuration I use:
define dumptype comp-tar { program "GNUTAR" compress fast index yes record yes auth "ssh" exclude list optional ".amanda-exclude.list" }
Now you need to create the exclude files where needed, named “.amanda-exclude.list”. I usually use two of those files. One in the root of the file system with the following content:
./Volumes ./Applications ./Library ./Users ./home
This excludes the other Mac volumes (that are mounted in the /Volumes directory) and the other defined Amanda volumes (the word “volume” is used on both contexts which may lead to confusion, but you want to exclude both kinds of volumes, so it’s ok). If you’re wondering about /home, it has no useful content (I suppose it’s there just for compatibility with some UNIX tools) and causes problems if not excluded.
The second file would go in /Users directory, and contain something like this:
./<user>/Music ./<user>/Documents/Virtual Machines.localized
Replace <user> with the username of the machine user, and duplicate the lines for additional users. This would exclude the user’s music directory and the VMWare disk images. Of course, your milage may vary. If you want to backup everything, just don’t add this second file.
You should now have a perfectly functional Amanda client.