Monday, 29 August 2011

Creating a mksysb backup to tape


Question
Mksysb related questions / how to create and restore.
Answer
This document discusses the ‘mksysb’ command when ran to a tape drive (rmt device).

What is a mksysb and why create one ?
Mksysb tape structure
Files important to the mksysb
Important information concerning mksysb flags
Creating a mksysb to a tape drive in AIX V5
Creating a mksysb to a tape drive in AIX V6
Verification of a mksysb
Restoring a mksysb
Restore menus
Restoring individual files or directories from a mksysb tape
FAQ


*Note : For all examples the tape drive will be refered to as /dev/rmt0. This may not be the case in your environment. Simply substitute the correct tape drive # as needed. Furthermore, this document does not cover restoring mksysb images to systems other than the one it was taken from (cloning). 

What is a mksysb and why create one ?
A mksysb is a bootable backup of your root volume group. The mksysb process will backup all mounted JFS and JFS2 filesystem data. The file-system image is in backup-file format. The tape format includes a boot image, system/rootvg informational files, an empty table of contents, followed by the system backup (root
volume group) image. The root volume group image is in backup-file format, starting with the data files and then any optional map files.

When a bootable backup of a root volume group is created, the boot image reflects the currently running kernel. If the current kernel is the 64-bit kernel, the backup's boot image is also 64-bit, and it only boots 64-bit systems. If the current kernel is a 32-bit kernel, the backup's boot image is 32-bit, and it can boot both 32-bit and 64-bit systems.

In general the mksysb backup is the standard backup utility used to recover a system from an unusable state - whether that be a result of data corruption, a disk failure, or any other situation that leaves you in an unbootable state. You should create a mksysb backup on a schedule in line with how often your rootvg data changes, and always before any sort of system software upgrade.

A mksysb tape can also be used to boot a system into maintenance mode for work on the rootvg in cases where the system can not boot into normal mode.

Mksysb tape structure

When creating a mksysb to tape, 4 images are created in total.+---------------------------------------------------------+ | Bosboot | Mkinsttape | Dummy TOC | rootvg | | Image | Image | Image | data | |-----------+--------------+-------------+----------------| |<----------- Block size 512 ----------->| Blksz defined | | | by the device | +---------------------------------------------------------+

Image #1: The bosboot image contains a copy of the system's kernel and specific device drivers, allowing the user to boot from this tape.blocksize: 512 format: raw image files: kernel device drivers 

Image #2:
The mkinsttape image contains files to be loaded into the RAM file system when you are booting in maintenance. blocksize: 512 format: backbyname files: ./image.data, ./tapeblksz, ./bosinst.data and other commands required to initiate the restore. 

Image #3:
The dummy image contains a single file containing the words "dummy toc". This image is used to make the mksysb tape contain the same number of images as a BOS Install tape. This is merely reference to pre-AIX V4 days when AIX was installed from tape.

Image #4: The rootvg image contains data from the rootvg volume group (mounted JFS/JFS2 file systems only). blocksize: determined by tape drive configuration on creation format: backbyname (backup/restore) files: rootvg, mounted JFS/JFS2 filesystems WARNING: If the device blocksize is set to 0, mksysb will use a hardcoded value of 512 for the fourth image. This can cause the create and restore to take 5-10 times longer than expected. You should set your tape drive’s block size to the recommended value for optimal performance.

Files important to the mksysbThere are a few files that the mksysb uses in order to successfully
rebuild your rootvg environment. These files are located on the 2nd image of your mksysb tape. Three of the files you may find yourself working with are described below.

bosinst.data : This file can be used to pre-set the BOS menu options. Selections such as which disk to install to, kernel settings, and whether or not to recover TCP related information can all be set here.
This file is mainly used for non-prompted installations. Any option selected during a prompted install will override the corresponding setting in this file. 

 image.data : This file is responsible for holding information used to rebuild the rootvg structure before the data is restored. This information includes the sizes, names, maps, and mount points of logical volumes and file systems in the root volume group. It is extremely important that this file is up to date and correct, otherwise
the restore can fail. It is common to edit this file when it is necessary to break mirroring during a restore.

 tapeblksz : This is a small text file that indicates the block size the tape drive was changed to in order to write the 4th image of the mksysb. This information would be useful if you wanted to restore
individual files/directories from your mksysb image.

Important information concerning mksysb flags

It is very important that you understand the use and intent of a few of the flags used by the mksysb command. Improper use, lack of use, or use of certain flags in certain situations could cause your mksysb to be difficult to restore. In some cases it may cause your mksysb to be unrestorable.

-i : Calls the ‘mkszfile’ command, which updates the image.data file with current filesystem sizes and characteristics. This flag should always be used unless there is a very specific reason you do not wish to have this information updated. Failure to have an accurate image.data file can cause your mksysb restore to fail with “out of space” errors. 

-e : Allows you to exclude data by editing the /etc/exclude.rootvg file.

A few tips on excluding data from your mksysb are listed below :

There should be one entry per line of the file. It can be either a single file or directory name.
The correct format of each entry should be ^./<path>
Never use wildcards.
Do not leave extra spaces or blank lines in the file. 

While the /etc/exclude.rootvg file excludes data, bear in mind that it does not exclude the fact that a filesystem exists. For example if you have a 50Gig filesystem “/data” and add an entry in your /etc/exclude.rootvg file :
^./data

This will exclude all files in /data but it will still recreate the /data filesystem as a 50Gig filesystem (except it will now be empty).
The only way to truly exclude a filesystem from your mksysb would be to unmount the filesystem before initiating your mksysb.
-p : Using this flag disables the software compression algorithms.

When creating a mksysb during any level of system activity it is recommended to use the “-p” flag. Failure to do so can cause “unpacking / file out of phase” errors during your mksysb restore.

These errors are fatal (unrecoverable) errors. No warning is given during the creation of the mksysb that notifies you of the possibility of having these errors during the restore.

You may want to make the “-p” flag compulsory when running your mksysb command so you do not run into this situation.

-X : This flag will cause the system to automatically expand the /tmp filesystem if necessary. The /tmp filesystem will require approximately 32Mb of free space.

For more information about these and other mksysb command flags, please refer the the mksysb man page.

Creating a mksysb to a tape drive in AIX V51. Using SMITTY : # smitty mksysb Backup DEVICE or FILE.........................[/dev/rmt0] Create MAP files?.............................no EXCLUDE files?................................no (-e) List files as they are backed up?.............no Verify readability if tape device?............no Generate new /image.data file?................yes (-i) EXPAND /tmp if needed?........................no (-X) Disable software packing of backup?...........no (-p) Backup extended attributes?...................yes Number of BLOCKS to write in a single output..[]
The only required selection here would be the tape drive to use for
the backup. Default flags are listed above. Change flags as necessary
for your environment / situation.
*Please refer to the section above entitled “Important Information Regarding Mksysb Flags"

2. From command line :# mksysb -i /dev/rmt0 

This command reflects the options listed in the above “smitty mksysb” output. This does not take into account any customization flags. Please review the section above entitled “Important Information
Regarding Mksysb Flags” to be best informed concerning the flags that you should use.

Creating a mksysb to a tape drive in AIX V61. Using SMITTY : # smitty mksysb Backup DEVICE or FILE.........................[/dev/rmt0] Create MAP files?.............................no EXCLUDE files?................................no (-e) List files as they are backed up?.............no Verify readability if tape device?............no Generate new /image.data file?................yes (-i) EXPAND /tmp if needed?........................no (-X) Disable software packing of backup?...........no (-p) Backup extended attributes?...................yes Number of BLOCKS to write in a single output..[] Location of existing mksysb image.............[] File system to use for temporary work space...[] Backup encrypted files?.......................yes Back up DMAPI filesystem files?...............yes
The only required selection here would be the tape drive to use for
the backup. Default flags are listed above. Change flags as necessary
for your environment / situation.
*Please refer to the section above entitled “Important Information Regarding Mksysb Flags"

There are a few extra options with V6 mksysb using SMIT. The most notable being the option “Location of existing mksysb image”. You can now use an existing mksysb taken to file and copy that to tape. An
attempt will be made to make the tape a bootable tape. You should use a system at the same or higher technology level as the mksysb image if you choose to do this. The command line flag would be “-F”.

This does require a minimum of 100Mb free in /tmp. See the manpage

for further information. This flag was introduced as a command line option in AIX V5 (5300-05).

2. From command line :# mksysb -i /dev/rmt0 

This command reflects the options listed in the above “smitty mksysb” output. This does not take into account any customization flags. Please review the section above entitled “Important Information Regarding Mksysb Flags” to be best informed concerning the flags that you should use.
Verification of a mksysbThere is no true verification of the “restorability” of a mksysb other than actually restoring it. Taking cautions such as understanding the flags used for the creation of the mksysb, checking your error report for any tape drive related errors before running the mksysb, regular cleaning of the tape drive, and verifying the readability of the mksysb after creation are all good checks. If your system is in good health your mksysb should be in good health. Similarly, if you attempt to create a mksysb of a system
logging hundreds of disk errors, or a system with known filesystem corruption, your mksysb will likely retain that corruption.

To verify the readability of your backup run the following command :
# listvgbackup -Vf /dev/rmt0

Any errors that occur while reading the headers of any of the files will be displayed, otherwise only the initial backup header information will be displayed. Keep in mind that this check tests the readability of the
file only, not the writeability.
Restoring a mksysbTo restore a mksysb image you simply need to boot from the tape and verify your selections in the BOS menus. Next, we’ll cover two booting scenarios. One in which your system is currently up and operational, the next in which your system is down.

1. If your system is currently running and you need to restore your mksysb, simply change the bootlist to reflect the tape drive and reboot the system.
# bootlist -m normal rmt0 
# shutdown -Fr 
 
2. If your system is in a down state you should boot to the SMS menus and set your bootlist to reflect the tape drive. The SMS menu options are listed below. Your menu options may be different (depending on
your level of firmware), however it should be clear enough by following this document to figure out what options should be chosen if yours differ.

SMS - SYSTEM MANAGEMENT SERVICES - 1. Select Language 2. Change Password Options 3. View Error Log 4. Setup Remote IPL (RIPL (Remote Initial Program Load)) 5. Change SCSI Settings 6. Select Console --> 7. Select Boot Options
The next menu should come up : --> 1. Select Install or Boot Device 2. Configure Boot Device Order 3. Multiboot Startup
The next menu will have the following : Select Device Type : 1. Diskette 2. Tape 3. CD/DVD 4. IDE 5. Hard Drive 6. Network --> 7. List all Devices 

The system will scan itself to determine which devices are available to boot from. All of your available boot devices will be displayed here. This menu can be a little tricky. If you have a device pre-selected it
will have a 1 next to it under the “Current Position” column. Use the “Select Device Number” listing to choose the device you want to boot from to change that. 

The next screen will offer you three choices :
1. Information --> 2. Normal Mode Boot 3. Service Mode Boot

Restore menusI. From the Installation and Maintenance Menu, select (2):
1) Start Installation Now with Default Settings 
2) Change/Show Installation Settings and Install 
3) Start Maintenance Mode for System Recovery 
 
II. From the System Backup Installation and Settings, you’ll see the default options that are taken from your “bosinst.data” file. If these are correct select (0) and skip down to step 6 below.
If you need to change any options such as the disks you would like to install to select (1):

Setting: Current Choice(s): 1. Disk(s) where you want to install... hdisk0 Use Maps............................ No 2. Shrink File Systems................. No 0. Install with the settings listed above. 
 
To shrink the file systems to reclaim allocated free space, select option 2 so the setting is set to Yes. For the file systems to be restored with the same allocated space as the original system, make
sure option 2 is set to No.

III. Change Disk(s) Where You Want to Install.Type one or more numbers for the disks to be used for installation and press Enter. 
The current choice is indicated by >>>. To deselect a choice, type the corresponding number and press Enter. At least one bootable disk must be selected. 
Choose the location by its SCSI ID. Name Location Code Size (MB) VG Status Bootable >>> 
1. hdisk0 00-01-00-0,0 70008 rootvg yes >>> 
2. hdisk1 00-01-00-1,0 70008 rootvg yes 0. Continue with the choices indicated above
After the desired disks have been chosen, select (0) to continue.

IV. System Backup Installation and Settings, select (0 to continue)Setting: Current Choice(s): 1. Disk(s) where you want to install......... hdisk0... 2. Use Maps.................................. No 3. Shrink File Systems....................... No 0. Install with the settings listed above.

Restoring individual files or directories from a mksysb tapeYou may at some point need to restore a file, several files, or directories from your mksysb. You’ll need to first find the block size the rootvg data was written at (4th image). Files will be restored relative to your current location on the system when the restore command is executed. If you would like the files to return to their original location run the restore command (step 3) from /, otherwise cd down to the path you wish the file(s) to be restored.


1. Display the contents of the ./tapeblksz file on the mksysb to determine the correct block size the tape drive should be set to for the restore command.

# cd /tmp 
 # tctl -f /dev/rmt0 rewind 
# chdev -l rmt0 -a block_size=512 
 # restore -s2 -xqvdf /dev/rmt0.1 ./tapeblksz 
 # cat ./tapeblksz 
 
The output that is given is the blocksize to which the tape drive was set when the mksysb was made.

2. Next, set the blocksize of the tape drive accordingly by running the following command :
# chdev -l rmt0 -a block_size=<number in the ./tapeblksz file> 

3. Restore the files or directories by running the following commands :

# cd / (if the file is to be restored to its original place) 
# tctl -f /dev/rmt0 rewind # restore -s4 -xqdvf /dev/rmt0.1 ./<pathname> 

You can specify multiple <pathname> entries for multiple file(s)/directory structures to restore. Simply separate each entry with a space. Remember to always use a “./” before each pathname.

**As an alternative you can also use the 'restorevgfiles' command. In the interest of keeping this document "relatively" short - no further examples will be given. Please see the manpage for use of this
command.

FAQThis section is included to provide answers to common questions asked concerning mksysb. This section is not intended to diagnose any problem or perform any problem determination. These questions/answers are intended to hopefully prevent the need to call up and open a problem ticket for a short duration / short answer
question. If you have any questions that you feel might be helpful, please submit feedback on this document and it may be added. 

1. The rootvg on my mksysb tape has all JFS filesystems, and I’d like to change them to JFS2 filesystems. 

How can I do this ?
The only supported method of changing rootvg system filesystems from JFS to JFS2 would be to run a “New and Complete Overwrite” installation.

2. Does the mksysb command backup nfs mountpoints ? 
No, nfs mountpoints are not followed.

3. Will my non-root volume groups automatically mount after the restore completes ?
That volume group setting is held on the VGDA of the disk the volume group is held. There is a new option that will allow this to be set in the BOS menus, so this should no longer be an issue. 

4. The document mentions I can restore files from my mksysb.
Are there any restrictions to what I should/should not restore ?
Absolutely. You do not want to restore any files that are critical to the system running.
Examples of files you do not want to restore: most library files, ODM files, applications, the kernel...
Examples of files safe to restore : /etc/group, /etc/passwd, cron related files, /home, any data filesystems you created....

5. How long will my mksysb take to restore ?
That is dependent on many factors - the amount of data that needs to be restored being the major player in the restore time. A ballpark rule of thumb would be 1.5 - 2x the time it took to create the mksysb. You
also have to consider reboot time.

6. The restore appears to be hung at 83%, what do I do ?
First you want to make sure this is a “true” hang. This point in the restore can take anywhere from 10 minutes to even upwards of 60 minutes depending on the size of the rootvg. Make sure you’ve given
it ample time to bypass this portion of the restore before becoming concerned.

7. I have a mksysb tape but I don’t know anything about it. Are there any commands that I can run to get information about the rootvg it contains ?
There are some very helpful ‘lsmksysb’ commands that can provide all sorts of information. Some of the things you can find out : - the ‘lslpp -L’ output to see what filesets are installed on that rootvg
- ‘lsvg -l rootvg’ output will show: 
volume group information and oslevel total backup size and size of volume group if shrunk to minimum

No comments:

Post a Comment

Twitter Bird Gadget