štvrtok 9. februára 2012

Creating bootable system backup tape on other server (for AIX)

Creating bootable system backup tape on other server (for AIX)
Lately I needed to make system backup from remote AIX servers, but have it saved to a tape on local machine. And I found out that things are not that simply. I found just handfull of resources on internet, but none that would be comprehensive and fully reliable, and none official from ibm. So I started my quest for the proper procedure.

I spent quite some time with it, but I will present my results in very concise form.

First, a bit of theory:

A bootable tape as a result of mksysb contains 4 records (set of data).

1. boot image - should contain all drivers from and for backed up server, so I reccomend to create own image for every backed up server (Doesnt take a lot of time anyway)
2. mkinsttape image - contains some install data and structure and mountpoints of rootvg
3. dummy "Table of Content" record - not used, it is here only for some compatibility reasons
4. mksysb image - archive of rootvg files - the "core" part of tape

"Terminology"

To distinguish servers I will reffer to them:

1. remote - the one that will be backed up
2. local - the one where we will write to the tape

Preparation of files on remote server

I will use below variable in my explanation:
$WORKDIR=/bla/bla - this is directory where prepared images will be stored.

The procedure will look like:

#1. Bootable image
bosboot -ad /dev/rmt0 -b $WORKDIR/1_bosboot.img
#2. Mkinsttape image
mkinsttape $WORKDIR/2_mkinsttape.img
#3. mksysb image
mksysb -e -i -p $WORKDIR/4_mksysb.img #swith -e is for exluding files, it is optional only

So the result is three files in $WORKDIR:
1_bosboot.img
2_mkinsttape.img
4_mksysb.img

(Yes, the number in names indicates final order on the tape)

This is all we need to do on remote server and now we go to local server to create the tape. Of course, copy the above files to local server first.

Work on locale server

In this part we will use 2 variables:

$RMTDEVICE=rmt0 - as example
$WORKDIR=/bla/bla - directory with above images

Preparation of tape

chdev -l ${RMTDEVICE} -a extfm=yes
tctl -f /dev/${RMTDEVICE} rewind
chdev -l ${RMTDEVICE} -a block_size=512
tctl -f /dev/${RMTDEVICE} rewind

#1 Saving bosboot image to tape
dd if=$WORKDIR/1_bosboot.img of=/dev/${RMTDEVICE} bs=512 conv=sync

tctl -f /dev/${RMTDEVICE} rewind
tctl -f /dev/${RMTDEVICE}.1 fsf 1

#2 Saving mkinsttape image to tape
dd if=$WORKDIR/2_mkinsttape.img of=/dev/${RMTDEVICE}.1 bs=512

tctl -f /dev/${RMTDEVICE} rewind
tctl -f /dev/${RMTDEVICE}.1 fsf 2

#3 Create & save dummy TOC to tape
echo "Dummy tape TOC" | dd of=/dev/${RMTDEVICE}.1 bs=512 conv=sync

tctl -f /dev/${RMTDEVICE} rewind
tctl -f /dev/${RMTDEVICE}.1 fsf 3

#4 Write mksysb file to tape (4/4)
dd if=$WORKDIR/4_mksysb.img of=/dev/${RMTDEVICE}.1 bs=512

tctl -f /dev/${RMTDEVICE} rewind # optional

And that is all, of course you can partially check the tape with command

lsmksysb -V -f /dev/${RMTDEVICE}

this will check readability and consistency of mksysbfile and whether is located as fourth record on tape. But it seems that only reliable test if the tape is functional is to boot from the tape.

Issues:
I dont have procedure for situation when backup can not fit to single tape. In such case use "exclude files swith: -e" , in fact it is listed above, but to be effective you need /etc/exclude.rootvg file with appropriate content)

This should be all, feel free to ask&comment