justlinux.com
Sun, 27-May-2012 11:39:19 GMT

Forum: Registered Users: 76222, Online: 301
nhfs Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Calendar Find other members Frequently Asked Questions Search Home Home

Help File Library: Amanda Network Backup Made Easy


Written by: Jeff Heckart

Introduction
     Background
     Installation
Configuration
     amanda.conf
     disklist
     Node Configuration
Using Amanda
     Tape Labeling
     Checking Amanda
     Running Amanda
     Restoring
Strategies
Conclusion

Introduction

top

This Help File is definitely written toward the more advanced *nix user, but can certainly be figured out by the beginner! This is geared not necessarily as a step by step (since each configuration is totally different), but a general guide to give you an idea of how the software works and what file to setup, as well as a guide of setting up the configuration. You will probably not be able to skim this, sit down and do it. It is not the easiest software to setup...especially if you are like me and do not necessarily come from a background of networking and tape backup. Hopefully this document will help, but if you get stuck...check your man pages, or feel free to email me-- I will help if I can.

Background

top

First, a little background on the software, and the way that it will be setup. Amanda is an open source network tape-backup system. An amanda setup will consist of a dedicated host tape server, and the clients. You will get the same same tarball for each *nix host, but will configure the nodes differently than the server.

Installation

top

The first thing that you will want to do is obtain the newest tarball of amanda from ftp.amanda.org. You will then need to type:

gunzip amanda.1.4.1p1.tar.gz

then type:

tar -xvf amanda.1.4.1p1.tar

The next step to take can be complicated depending on what exactly your setup of amanda will be. I will go ahead and give you what I did and explain each step. I compiled mine by first moving to the amanda-1.4.1p1 source directory and running:

"./configure --with-config=porky --with-user=amanda --with-group=operator --with-smbclient=/usr/local/samba/smbclient --with-??"

If you do a "./configure --help", it will give you all of the options that you have. As you can see, the compilation of amanda is different than most of the programs that you have compiled, and will be difficult unless you are an amanda guru...which is unlikely since you have read thus far. My compilation flags are somewhat generic and might be exactly what you want to use.

Ok...where to start...the first flag that you see there is "--with-config=porky". porky just happens to be the box that I will be backing up, and this it the name of the configuration. I use that mainly for organizing amanda as it can be confusing...this way all of my source files that will be discussed later will go into the porky directory. Ok, next both the --with-user= and the --with-group= are the only two required parameters during compilation (amanda will not build without both of those). You will want to create the user "amanda", which will be the one who runs the backups. You will also want to add amanda to the operator in /etc/groups. The user could be anything...I again chose amanda for the benefits of keeping the system clean. I do not really know if putting amanda in the operator group is a great move security wise though. I do not know enough about security to say whether or not this would be a problem though.

The last flag that I include is the "--with-smbclient=/usr/local/samba/smbclient". I use this because I do have samba(another great piece of open source software), and I want to backup my MS-OS machines through amanda. All that you need to specify in this flag is the path of your smbclient. This is by no means a required step.

At this point I ran the command that I have been talking about, and moved onto make...and yes amanda was not just satisfied with make...there is more! Since I was doing this in FreeBSD 4.0, I had a problem with compiling the "changer-src", which is simply the ability to use a tape changer, which in my case--I could care less about...unfortunately "make" cares (FYI -- I used amanda later on BSDI and had no problems with the changer stuff...I would not expect any problems with a linux os either). If you are building this on FreeBSD and you have this problem, edit the Makefile and remove the one line that has changer-src in it, and you should "make" just fine. Next, you will simply need to run "make install" (yes with no modifications!).

Configuration
amanda.conf

top

Now that the installation is complete, go ahead and look in your dmesg ("dmesg | more"), and find the device file of your tape drive...and make a note of it. You will want to update your locate database at this time, as it will be very helpful to you. The two major configuration files -- "amanda.conf" & "disklist" the files in amanda that hold your settings for the tape drive and for the partitions that you will backup, and other important variable settings for amanda. Now, copy your amanda.conf and disklist files from your examples directory, to the directory that you specified in the configure command (for me, it was the mics directory). The file that you want to start with is the amanda.conf, now would be a good time to dig out the amanda.conf man page and dig in. Another great source is. Other than that source, i will leave you to the amanda.conf file. Once you know what your tape drive is and how it performs, the amanda.conf file is somewhat self-explanitory. As a side note, make sure that you specify a working email address in amanda.conf for amanda to send to....we will need the mail later for diagnostics.

Disklist

top

Now....for the disklist file -- it also is very self-explanatory. First, if you have not already, copy the existing example "disklist" file to the directory holding amanda.conf. It is, for the most part, fine to follow the existing format of the example file with the exception of the host names. I have seen the host names work, but that was when a hosts file was setup on the machine, which can be a huge pain when dealing with many nodes. I have been unable to have amanda work with non-canonical host names using bind alone. As a matter of fact, I setup amanda using the full numerical ip address every time....seems to work easiest that way.

Node configuration

top

For each node that will be backed up, you will need to configure a couple of files.
The first file is /etc/inetd.conf. You must add these lines:

amanda dgram udp wait amanda /usr/libexec/amandad amandad
amandaidx stream tcp nowait amanda /usr/libexec/amindexd amindexd
amidxtape stream tcp nowait amanda /usr/libexec/amidxtaped amidxtaped

You will next want to add a file .rhosts under your user root and user amanda directory and add the following lines:

192.168.0.1 amanda
#use the actual ip of the backup machine
server           amanda 
#use the actual host of the backup machine

You will then need to reboot for the rhosts changes to take effect.

Using amanda Tape labeling with amlabel

top

Now that we have the server and hosts all setup, we need to start setting up the tapes. You will need to decide how many tapes to use and how you desire to label them....for example, I label mine "porky1", "porky2", "porky3" etc. You will now want to become root, insert the first tape in the drive and label it with the following command: `su amanda -c "amlabel porky porky1"`. EXPLANATION -- the first part simply runs the program as amanda. The second part (amlabel), is the program included in amanda that labels your tapes. The third portion (porky), specifies the configuration name that you specified in amanda.conf (I used porky just to keep things organized). The fourth portion (porky1), is simply the label that I will put on the tape. Amanda will save each of these tape labels in the tapelist file, so do not label two tapes with the same label.

If you need to relable or remove a tape from the list, become root, and use `su amanda -c "amrmtape porky porky1"`. This will remove the tape from the list and allow you to relable.

Checking amanda with amcheck

top

At this point, amanda should be setup, and all that you will need to do is make small changes as a problem arises. Before trying to run amanda, you will defenitely want to pass amcheck. Amcheck tests your configuration files and communication with the hosts in the disklist file as well as the tape in the drive and the drive itself. Run amcheck using `su amanda -c "amcheck porky"`. One of the first problems that you will encounter is a permissions problem....any file(s) that throws a permission problem at you, just change the ownership of the file to amanda.opertor ie. `chown amanda.operator file`. Then also make sure that you give appropriate permissions to the file. You are also very likely to have problems because directories and/or files do not exist. Simply `touch` any files and mkdir any directories that you need. Make sure to double check your permissions and ownership for the directories and files that you made also.

Once you get past the initioal problems with directory and file permissions, you may occur an issue with the communication with the other nodes on the network, or even possibly with the tape-server itself. If you do have issues with communication, make sure that the following files are accurate to the configurations previously discussed: /etc/inetd.conf ~amanda/.rhosts.

The only other typical problem that could occur here is an issue with the tape or drive. Any problems with the tape could possibly be due to a labeling issue, which would require you to relabel. Anything else concerning the drive could have something to do with the configuration of the drive in amanda.conf.

Now that we have amcheck giving the go ahead, we are ready to move on to actually running amanda backup.

Running and monitoring amanda

top

You will run amanda using `su amanda -c "amdump porky"` (I would definitely recommend running this in the background). This will now start the backups by gzipping the items to be backed up on the machine being backed up....the gzipped files will then be dumped to the holding disk specified in amanda.conf (which is why your holding disk should be somewhat proportional to the amount being backed up). The dumps will then be passed on to the tape. The time that this will take could be huge -- all relative to the condition and speed of the network, speed of the tape drive, the speed of the tape-server, and obviously the size of the partitions being backed up.

There is one way to check on the status of the current backup -- you guessed it...amstatus. You will do so by running `su amanda -c "amstatus porky". Another thing that I ocassionly do is run `top` to check the resources that it is taking. It will also take a considerable amount of system resources from the box being backed up, so you will also want to run a top on the machine being backed up if it is a production machine (which why would you back anything up that wasn't production?).

The message of completion will be sent to the address(es) specified in amanda.conf. It will list statistics and time taken etc. Amanda will also send a message of failure with the reason upon failure.

Restoration of data from amanda

top

Ok, hopefully you never get to this point, but, it is definitely nice to know what to do just in case!

I will give an example of how to recover the data of a non-os disk partition, mainly because the root partition on a system should be only the os. Anyone using any sort of backup with like 2gig root partitions should rethink why that may be a bad idea....I will touch the surface of that a little later on in the article.

You will want to get to the computer needing to be recovered and switch to the directory under / where the data needing to be restored previously sat (i.e. to restore the file /home/jeff/public_html/index.html, you want to be in the / of the partition that home sits in). You will then be root, and run `su amanda -c "amrestore porky"`. This will talk with the tapeserver. Now, at the prompt, type "setdisk sd0f" (sd0f being the partition from where the data was originally backed up). You may also want to run "help", to see any other available options. You should now be able to use the prompt almost as if at a ftp site. Use ls to see what is available, and cd to change directory. When you find a file, or whole directory to extract, enter "add fileordir". Once all of the files that you want have been added, enter "extract", and this will prompt you for tapes. Speeking from experience, I would definitely spend some time with a development machine just messing it up and resoring it....to make sure that you can do it when the "2am on the spot recovery" is necessary!

Strategies

top

Ok, at this point you should probably have the whole amanda thing figured out to the point that you can back something up and restore it. There are several things here that at least need mentioning that have something to do with backups. The first thing would be the timiming. Due to the system resources that amanda will take it is almost necessary to run these during the time that the users will not complain about it. This would mean that you would want to run amdump through crontab at whatever time that you want. You will also need to decide what machines will need to be backed up and on what day and so on. You are probably also wondering how you could have different disklists. You can do so by having another directory for the amanda.conf and disklist file to reside in. That would mean that you would want to have for instance a server2 directory under the location of where the current porky directory is. Then you would have to go through the previous steps, for example: `su amanda -c "amcheck server2"`. You would then obviously put `su amanda -c "amdump server2"` in crontab for that specific set of systems on the particular day and hour of execution.

The other item that I hinted to earlier about the root partition for a *nix machine, is refering to the risks taken using one parition on the whole disk of a single disk system. If you make about a 100mb partition (which is usually generous) for root and then divide the rest out accordingly, you could still boot even if the data on a seperate partition was dead. It may be a pain and you would go into single user, but it would boot. The other situation would be if root went bad, then it would just need reinstalled and the rest of your data would be sitting comfortably behind the walls of the partition.

Conclusion

top

I hope that this Help File has been of some help to you. Feel free to email me for any questions or problems that you encounter, and I will at least try to answer you. Please understand that I am far from being an expert at *nix, I am 19 and have gained a decent level of understanding through experience alone. I am currently a freshman computer science major at Cedarville University in 2001. I will however help you however I can. Also, be sure to test everything and, I cannot say enough to test the restore....as I do not want to get hate mail from someone who thinks that they are backing up there important data and then finds that they can do nothing with it at the wrong time!

Good Luck!