How To:Build a Test Environment With Virtual Tapes

From wiki.zmanda.com
Jump to navigation Jump to search

This article is a part of the How Tos collection.

Here is a Quick Setup for a test configuration with a virtual tape changer, emulating tapes on disk.

Note that this article describes setting up vtapes specifically for a test environment. For a more complete description of virtual tapes and their use, see file driver and How To:Set Up Virtual Tapes.

A test environment is very handy to experiment with the more obscure features of amanda, or get more familiar with all the possible options in amanda.conf and the dumptype options. And you can practice restores quickly.

Let's call the configuration "test".

First find out where the configuration directory is, and create a new config, as user amanda:

$ amadmin x version | grep CONFIG_DIR
CONFIG_DIR=/etc/amanda
$ cd /etc/amanda
$ mkdir test


Copy a template amanda.conf(5) file to the directory created, and adapt the parameters to your environment. Here are some values:

Amanda 2.6.0 or below (old chg-disk):

org "Acme Inc."
mailto "[email protected]"
dumpcycle 7
runspercycle 5
tapecycle 5
dumpuser "amanda"
tpchanger "chg-disk"                            # a virtual tape changer
tapedev "file:/space/vtapes/test/slots"
changerfile "/var/lib/amanda/test/changerfile"
labelstr "TEST-.*"
#label_new_tapes "TEST-%%"
#autolabel "TEST-%%"
tapetype DVD_SIZED_DISK
logdir "/var/lib/amanda/test"
infofile "/var/lib/amanda/test/curinfo"
indexdir "/var/lib/amanda/test/index"
tapelist "/var/lib/amanda/test/tapelist"

holdingdisk hd1 {
    directory "/space/amandahold/test"
}

define dumptype comp-tar {
    program "GNUTAR"
    compress fast
    index yes
    record no           # Important! avoid interfering with production runs
}  

define tapetype DVD_SIZED_DISK {
    filemark 4 KB
    length 4482 MB
}


Amanda 2.6.1 or above (new chg-disk):

org "Acme Inc."
mailto "[email protected]"
dumpcycle 7
runspercycle 5
tapecycle 5
dumpuser "amanda"
tpchanger "chg-disk:/space/vtapes/test/slots"                            # a virtual tape changer
labelstr "TEST-.*"
#label_new_tapes "TEST-%%"
#autolabel "TEST-%%"
tapetype DVD_SIZED_DISK
logdir "/var/lib/amanda/test"
infofile "/var/lib/amanda/test/curinfo"
indexdir "/var/lib/amanda/test/index"
tapelist "/var/lib/amanda/test/tapelist"

holdingdisk hd1 {
    directory "/space/amandahold/test"
}

define dumptype comp-tar {
    program "GNUTAR"
    compress fast
    index yes
    record no           # Important! avoid interfering with production runs
}  

define tapetype DVD_SIZED_DISK {
    filemark 4 KB
    length 4482 MB
}


The above contains only the bare minimum. The idea of a test environment is just to add and change most of the values in amanda.conf.

Note: you may set "record yes" in the dumptype for those directories that are NOT used by any real Amanda config. It is ok to add "record yes" if the parent of a directory is part of another amanda config, but this is only a subdirectory of that directory.

Create some directories/files that we configured in amanda.conf:

# mkdir -p /space/amandahold
# chown amanda:disk /space/amandahold
# chmod 750 /space/amandahold
# su - amanda
$ mkdir /space/amandahold/test 
$ mkdir /var/lib/amanda/test
$ touch /var/lib/amanda/test/tapelist

And create the virtual tapes, making sure the dumpuser has access to the vtapes, but not everyone else on this server:

# mkdir /space/vtapes
# chown amanda:disk /space/vtapes
# chmod 750 /space/vtapes
# su - amanda
$ mkdir -p /space/vtapes/test/slots
$ cd /space/vtapes/test/slots
$ for i in 1 2 3 4 5; do mkdir slot$i; done
$ ln -s slot1 data

In the loop above: create as many slots as you have specified tapecycle in the amanda.conf. (Do not add a leading zero to the numbers.)

Quick test to verify the virtual tape setup:

# Amanda 2.6.0 and above:
$ amdevcheck <config> file:/space/vtapes/test/slots
# pre-2.6.0
$ ammt -f file:/space/vtapes/test/slots status

If OK, the ammt command should print "ONLINE", while the amdevcheck(8) should print "VOLUME_UNLABELED"

Then label the tapes:

$ for i in 1 2 3 4 5; do amlabel test TEST-$i slot $i; done

And reset the changer to the first slot again:

$ amtape test reset

Since Amanda version 2.5.0 you can also add the parameter label_new_tapes, ('autolabel as of version 3.1) which will automatically label any tape if needed -- very handy in this case (unless you want to test amlabel commands).

Now create a small disklist file:

amandaserver.example.com   /var/log   comp-tar
client1.example.com        /var/log   comp-tar

Configure the servers you added in the disklist as Amanda clients.

Run amcheck(8) and solve all issues.

And you're ready for the first test run:

$ amdump test

Resetting the environment

After some tests, you may want to start from scratch, removing all the garbage created while testing.

For this, remove the contents of the status directories and also the virtual tapes. But do not remove the directories or files themselves.

$ rm -rf /space/vtapes/test/slots/slot*/*
$ rm -rf /space/amandahold/test/*
$ rm -rf /var/lib/amanda/test/*
$ > /var/lib/amanda/test/tapelist

And amlabel the tapes again as above. When using the label_new_tape parameter (autolabel' as of version 3.1), Amanda will label them even automatically again.

Hopefully, you have made a safe copy of the "base" amanda.conf and disklist before starting the experiments, otherwise you'll have to walk through these files and inspect the values.