![]() | ||
Using Amanda for backupsAMANDA as the name says, is an advanced disk archiver or, more simply, a backup program. It's a really useful program, let down by something approaching the worst documentation out there. I've had about 4 attempts on and off for about the same number of years at using it and deciphering the documentation. Finally I got it to work, but it should not be that hard. Who knows, maybe in another 4 years I won't hate Wiki documentation? Naah. This document shows you what files you need to create, their format and how to use some of the programs. It's probably only a brief get you started type of document, but at least you should be able to start. I have tested this setup on a bunch of Debian GNU/Linux servers but it should be reasonably similar for other systems. Speaking of my systems, what I'm writing here works for me with my setup. It's quite likely it will work for you, but you should verify and test everything. If something is not quite right and you lose all your valuable files because something is wrong in here, you should of tested it properly yourself. In any case, a non-tested backup system is almost as useless as a non-working one. Determine your backup regime and other detailsThe first step is to decide what you want to backup. Do you want to do everything? Just home files? The variety is quite large and it is just a matter of working out how to tell AMANDA how to do it. AMANDA works in chunks of partitions, so if you have everything in one partition as / then that's one big chunk. All is not lost however as you can use some tricks to exclude some type of files or directories. For my setup, I backup all of /, most of /var except logs and cache and /home with the exception of some junk. The method for backing up all of a partition can be done differently than backing up part of it. I'm not sure, but I think its quicker to backup all of a partition when you can. Next, think of a name to call the backup regime. I call mine "normal" and thats what I'll use here. AMANDA calls the name "the config" in the manual pages. It's just a label for the set of configuration files. Determining tapetypeThe configuration file (see next section) will need to know the tapetype. If you don't know what drive model you have, you can often get some information about the device in the /proc/scsi/scsi file. My file shows my ancient Sony tape drive.
Attached devices: The tapetype is a bunch of parameters about your tape drive and they are different for every device. Have a look at AMANDA tapetype list to see if yours is there. Failing that, use the amtapetype program. Be warned, it will take a long time for this program to work. When I mean a long time, I'm talking about 2 hours or so. That's roughly how long it took for me.
To run it, type Main configuration file - amanda.confMost configuration information goes into the amanda.conf configuration file. The configuration files are kept into a place /etc/amanda/configname which for me is /etc/amanda/normal.
org "Example Company" # Title of report So what do all those lines mean? You can leave most of them what they are in this example. Read the amanda(8) manual page for information about what each of the lines does. I'll only point out some of the more significant or tricky ones here.
The tapetype definition have been previously explained. It's either going to be a cut and paste from a website or the output of amtapetype. The dumptypes depart from the usual ones you see in the amanda documentation. I am using tar here because then I can select what files and directories I want in the archive. The two dumptypes are identical except for the priority and the exclude-list. disklist config fileThe disklist file is found in /etc/amanda/normal/ directory and it lists what disks on what hosts are to be backed up using what backup format. Each line has three entries separated by whitespace: hostname, drive or partition and dumptype. The dumptype is one of the ones that was defined in the configuration file amanda.conf. My disklist looks like:
# disklist for normal backups Reading both this file and the amanda.conf file, you can see that this means /var is backed up using tar and gzip and it will use the exclusion file var.exclude and /home is backed up also using tar and gzip but with the exclusion file home.exclude. The tar exclude filesI create two exclude files, one for each partition type I am backing up. The contents of these exclude files are a file or directory name, one per line. You may want to read the GNU tar info files about what can go here, its just using the --exclude-from flag. My var.exclude excludes logs, debian packages, cached processed manual pages and temporary files, it looks like this:
/logs/*/*.gz Creating directories and filesThere are a fair few directories and files that AMANDA needs to have setup with the correct permissions before it will work. The easiest way to document this is to show you the commands used. Remember that my config name is "normal" and a lot of these directories are defined in the amanda.conf file as is the user.
chown backup.backup /etc/amanda/normal Making a new AMANDA tape
You will now need to make a new tape and label it. Put the tape in the
drive and use the command Checking the configurationAMANDA has a checking program, called amcheck, that makes sure everything is ready to go for the backup. The example output given below shows most things are ok, but I need to change a tape (and run amlabel on it) because I've already used this tape.
# su backup To do the backupAfter all that setup and testing, the backup itself is, well, pretty boring. To start it, as the backup user type /usr/sbin/amdump normal. You probably want this in a crontab so it is done regularly. After some time whoever was mentioned in the mailto line in the amanda.conf file will get an email about the backup. Recovering a fileTo test the backup, you really need to test that you can restore a file. To do this I cd to /tmp and then run the amrecover utility. The amrecover program looks a lot like a ftp client and is pretty easy to use. Once again, it needs the config name so to run it, type amrecover normal. It may not know what host you want to go to, so set the host with the sethost command.
amrecover> sethost localhost Next you need to tell the recover program what disk you are trying to recover. We'll select the /home directory here.
amrecover> setdisk /home We've found the disk and the host, now to wander around the filesystem and find the file. The file we are after is /home/csmall/myfile.txt. We've already at /home with the setdisk command, so now it is just a matter of cd into the csmall directory, add the file myfile.txt to the recovery list and then issue the extract command to start the recovery process.
amrecover> cd csmall The restore program has found the file you are after and what tapes are needed to restore the file. If there were many files there may be multiple tapes required. It will now ask you to continue and after pressing enter it will pause while you load the required tape into the drive. Pressing enter again will restore the file. It may take an hour or so to get it.
Extracting files using tape drive /dev/nst0 on host localhost. The result should be now a restored csmall/myfile.txt in your current directory. If that's the case, the restore test has succeeded. other stuff mt -f /dev/nst0 datcompression mt -f /dev/nst0 status | ||
Last Modified: Tue, 22 Jul 2008