How To:Mirror Dumps to Virtual Tapes and Real Tapes using RAIT

From wiki.zmanda.com
Revision as of 22:24, 21 January 2008 by Dustin (talk | contribs) (move some stuff to RAIT Device)
Jump to navigation Jump to search

This article is a part of the How Tos collection.

See RAIT Device for a brief description of the RAIT Device.

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