How To:Mirror Dumps to Virtual Tapes and Real Tapes using RAIT
This article is a part of the How Tos collection.
See RAIT Device for a brief description of the RAIT Device.
RAIT with 3 autoloaders example setup
Disclaimer: Known to work on Solaris with Sony TSL-9000 autoloaders and amanda-2.6.0p2, YMMV.
This assumes that you have a working configuration named Dailyset1 and all the non-RAIT parameters have been set.
It is probably easiest to set up and test a non-RAIT configuration, and once that works, make the following modifications to convert to a RAIT setup after deleting all log files, everything under curinfo/ and emptying the tapelist and tapelist.amlabel files.
Set the following in amanda.conf:
tpchanger "chg-rait-mod" # the tape-changer glue script (chg-rait modified, see below) tapedev "rait:tape:/dev/rmt/{0,1,2}ln" # the no-rewind tape devices changerfile "/usr/local/etc/amanda/Dailyset1/changer.conf" # tape changer configuration parameter file #changerdev # tape changer configuration parameter device (not used here)
In changer.conf:
# nchangers=3 # tpchanger_1="chg-zd-mtx_1" # modified chg-zd-mtx, see below changerdev_1="/dev/scsi/changer/c3t4d1" # changer device changerfile_1="/usr/local/etc/amanda/Dailyset1/changer1.conf" # device specific config file #tapedev_1 # not used # tpchanger_2="chg-zd-mtx_2" # modified chg-zd-mtx, see below changerdev_2="/dev/scsi/changer/c3t5d1" # changer device changerfile_2="/usr/local/etc/amanda/Dailyset1/changer2.conf" # device specific config file #tapedev_2 # not used # tpchanger_3="chg-zd-mtx_3" # modified chg-zd-mtx, see below changerdev_3="/dev/scsi/changer/c3t6d1" # changer device changerfile_3="/usr/local/etc/amanda/Dailyset1/changer3.conf" # device specific config file #tapedev_3 # not used
In the changerX.conf files (one file for 3 identical loaders should be OK, but not tested):
# Device specific parameters for the loaders. See the comments at the start of chg-zd-mtx for details # firstslot=1 lastslot=7 havereader=0 autoclean=0 poll_drive_ready=5 initial_poll_delay=5 cleanslot=8 #
Modified Files
Copy chg-zd-mtx to chg-zd-mtx_N, i.e. _1, _2, and _3.
For each file, find the sections that set changerfile, rawtape, and TAPE, comment out those blocks and explicitly set the values to your values as shown below for chg-zd-mtx_1.
#changerfile=`amgetconf changerfile 2>/dev/null` #if [ -z "$changerfile" ]; then # Exit 2 \ # `_ '<none>'` \ # "changerfile must be specified in amanda.conf" #fi changerfile="/usr/local/etc/amanda/Dailyset1/changer1.conf"
#rawtape=`amgetconf tapedev 2>/dev/null` #if [ -z "$rawtape" ]; then # Exit 2 \ # `_ '<none>'` \ # "tapedev may not be empty" #fi rawtape="/dev/rmt/0ln"
#TAPE=`amgetconf changerdev 2>/dev/null` #if [ -z "$TAPE" ]; then # Exit 2 \ # `_ '<none>'` \ # "changerdev may not be empty" #elif [ $TAPE = "/dev/null" ]; then # Exit 2 \ # `_ '<none>'` \ # "changerdev ($TAPE) may not be the null device" #fi TAPE="/dev/scsi/changer/c3t4d1"
Note: chg-zd-mtx as supplied gets it's configuration from amanda.conf and is called by chg-rait 3 times, once for each loader. The clean fix would be to modify chg-zd-mtx to optionally accept explicit configuration information from the caller and modify chg-rait to provide it from the changer.conf file.
RAIT expects all 3 loaders to be in sync, that is all loaders are in the same state, have the same number of tapes, and all tapes have the same labels in corresponding slots.
Test your configuration.
Try amtape Dailyset1 reset and all the loaders should load slot 1 and amtape Dailyset1 current should show slot 1 as loaded.
You may get some warnings, but if all loaders load properly, ignore them.
With slot 1 loaded for all loaders, label the tapes.
amlabel -f Dailyset1 Dailyset1-001 amtape Dailyset1 slot next amlabel -f Dailyset1 Dailyset1-002 amtape Dailyset1 slot next . . .
And so on until all tapes are labeled.
Load slot 1 (amtape Dailyset1 slot 1) and do a test backup (amdump Dailyset1).
Disaster Recovery from a RAIT tapeset
When performing a manual restore from a RAIT tapeset, you can just use amrestore on the device, like so:
$ amrestore -f 10 'rait:/dev/rmt/tps0d{4,5,6}n'
Mirroring a backup
RAIT with only two drives, creates a perfect copy of the data: a mirror of your backup. Each of these mirrors is handled by its own output driver: one of the mirrors can write to a real tape device, and the other mirror can write a virtual tape (vtape) using the "file" driver. The vtapes can be used for fast recovery, and the tapes can be stored offsite.
Together with the "chg-multi" changer, which is suitable for a whole range of applications, this setup requires these parameters in amanda.conf (the parameters dumpcycle, runspercycle and tapecycle should be adapted to your environment):
dumpcycle 1 week runspercycle 5 tapecycle 10 tpchanger "chg-multi" changerfile "chg-multi-mirror.conf" # tapedev is not needed # changerdev is not needed
We create the file chg-multi-mirror.conf in the same directory, with these contents:
multieject 0 needeject 0 gravity 0 ejectdelay 0 statefile /home/amanda/daily/changerstatus firstslot 1 lastslot 10 slot 1 rait:{file:/amandatapes/daily/vtape1,tape:/dev/nst0} slot 2 rait:{file:/amandatapes/daily/vtape2,tape:/dev/nst0} slot 3 rait:{file:/amandatapes/daily/vtape3,tape:/dev/nst0} slot 4 rait:{file:/amandatapes/daily/vtape4,tape:/dev/nst0} slot 5 rait:{file:/amandatapes/daily/vtape5,tape:/dev/nst0} slot 6 rait:{file:/amandatapes/daily/vtape6,tape:/dev/nst0} slot 7 rait:{file:/amandatapes/daily/vtape7,tape:/dev/nst0} slot 8 rait:{file:/amandatapes/daily/vtape8,tape:/dev/nst0} slot 9 rait:{file:/amandatapes/daily/vtape9,tape:/dev/nst0} slot 10 rait:{file:/amandatapes/daily/vtape10,tape:/dev/nst0}
This assumes we have only 1 tapedrive (/dev/nst0), which we need to manually change the tape each day.
RAIT with a real tape changer is not supported.
- NOTE: this needs more clarification: what about chg-manual, and chg-rait?
We create the 10 virtual tapes:
$ for i in 1 2 3 4 5 6 7 8 9 10; do mkdir -p /amandatapes/daily/vtape$i/data; done
We insert a tape in the physical tapedrive, and label the first tape. This will label both the virtual tape vtape1 and the tape in the physical drive identically:
$ amlabel daily DAILY-01 slot 1 $ amcheck daily
Last check, and we are ready for the normal amdump run.
When reading a RAIT set and an XOR sum mismatch is detected, this is flagged with the error:
EDOM (Numerical argument out of domain)
When the tape in the tapedrive is not the same label as the tape in the corresponding tape in the vtape set, the checksums of course do not match and you get the cryptic error:
amcheck-server: slot 2: reading label: Numerical argument out of domain
This means that the tapes in slot 2 do not match (or that one of the tapes had a read error). Finding out which tape each side of the mirror has, can be done with amdd:
$ ammt -t file:/amandatapes/daily/vtape2 rewind $ amdd if=file:/amandatapes/daily/vtape2 bs=32k count=1 AMANDA: TAPESTART DATE X TAPE DAILY-02 1+0 in 1+0 out $ ammt -t file:/amandatapes/daily/vtape2 rewind $ ammt -t /dev/nst0 rewind $ amdd if=/dev/nst0 bs=32k count=1 AMANDA: TAPESTART DATE X TAPE Test-03 1+0 in 1+0 out $ ammt -t /dev/nst0 rewind
In the example we see that the physical tape is actually labeled "Test-03", while we need the tape labeled "DAILY-02". Note that we always rewind the tape again when finished.
Using amrecover with half of the mirror
When needing to restore, you can use the specific vtape, or the physical tape. Just specify the correct device to amrecover (or amrestore) on the command line, or with the settape subcommand from amrecover.
# amrecover daily -d amandaserver.example.com:file:/amandatapes/daily/vtape5
Note that, when you specify the driver, you must specify the hostname too.
Alternatively, you could set up a special configuration for restoring, named "halfmirror" that is almost identical to the normal config, except for the chg-multi.conf: fill that file without rait option and only the virtual tape half of the mirror:
In the amanda.conf from the configuration named halfmirror:
tpchanger "chg-multi" changerfile "chg-multi-halfmirror.conf" amrecover_changer "halfmirror" amrecover_do_fsf true amrecover_check_label true
chg-multi-halfmirror.conf:
multieject 0 needeject 0 gravity 0 ejectdelay 0 statefile /home/amanda/daily/restorchgstatus # different name than the normal mirror firstslot 1 lastslot 10 slot 1 file:/amandatapes/daily/vtape1 slot 2 file:/amandatapes/daily/vtape2 slot 3 file:/amandatapes/daily/vtape3 slot 4 file:/amandatapes/daily/vtape4 slot 5 file:/amandatapes/daily/vtape5 slot 6 file:/amandatapes/daily/vtape6 slot 7 file:/amandatapes/daily/vtape7 slot 8 file:/amandatapes/daily/vtape8 slot 9 file:/amandatapes/daily/vtape9 slot 10 file:/amandatapes/daily/vtape10
By using a different name for statefile above, we do not interfere with the notion of current tape etc from the normal daily configuration. (This would not work with chg-disk.)
And recovering from this set of vtapes goes like:
# amrecover halfmirror -d halfmirror
Tip |
If you are short in diskspace, you can get fancy, and keep only the last 5 (runspercycle) vtapes online, by removing the contents of the data directory in each vtape that is older than runspercycle, except the first pair of files (the label). Even the "TAPEEND" pair of files is not strictly needed for Amanda. An erased vtape, with correct label then looks like:
$ ls -l /amandatapes/daily/vtape4 -rw------- 1 amanda disk 10 Mar 29 00:04 00000-DAILY-04 -rw------- 1 amanda disk 32768 Mar 29 00:04 00000.DAILY-04