Thursday 25 June 2009

Use Optical Media/DVDs for AIX backups





Using Optical Media for your backups on AIX


Optical Media like DVDs and CD-RW have been an inexpensive way of taking backups as compared to tape cartridges. With the passage of time, difference of prices between optical media cartridges and tape cartridges is also increasing with a sharp decline in optical media prices. On the other hand, there are many disadvantages in it (like in DVD usage). For example, DVDs are always slower than tape cartridges. DVD backups, therefore always take long periods to complete as compared to backups on tape cartridges.
Moreover DVD storage capacity is limited to about 4 GB, as compared to 20GB and more for tapes.

For windows system administrators, taking backups to these inexpensive DVD cartridges have been extremely easy job; on the other hand Linux system administrators also easily enjoy usage of these DVD cartridges for their day to day backups.

For IBM PSeries users and administrators, usage of DVD cartridges has not been a very simple task. First of all, many of them face difficulty in finding compatible DVD cartridges with DVD RAM drives which they have in their systems. Second, some of them face problems in deciding which technique to be used on AIX in order to utilize these DVD cartridges for their day to day backup operations. In this article, I will try to highlight different ways to use DVD cartridges for backup operations on AIX operating system and try to answer many basic questions which come to mind of an AIX system administrator while he goes to use DVD or CD-RW for taking system level backups.


Media & Compatible devices


The first and major question which arises for AIX system administrators is to select appropriate optical media for taking backups on pSeries. In this regard, you have to consider the device, which is being attached with pSeries box.
Following is the table from IBM support sites, which contain supported devices with compatible optical media for IBM pSeries boxes.





So you have to carefully determine which optical device you have on your system and then use the above table to find out compatible media for that device.
Most of latest IBM pSeries servers now come with DVD RAM devices which support DVD RAM cartridges. CD-RW devices are not orderable in most of circumstances. A most common DVD RAM drive from IBM, which is available on most latest IBM pSeries boxes is “IBM 4.7 GB IDE Slimline DVD-RAM Drive” with feature code 5751.You can order IBM DVD media for this drive ( part number of media is also mentioned in above table) or you can buy other vendor media which are easily available in market on much cheaper rates. While selecting non –IBM media, once again always concentrate on your drive type( you may use above tables as your reference), otherwise you may face non –compatibility errors while creating backups on these media. For example, I used type 2 DVD-RAM, single sided rewritable disc from Imation brand with IBM 4.7 GB IDE DVD-RAM drive for number of years without any problems.







Appropriate command selection for system backups


AIX 5L supports creation of bootable system backups, starting from AIX 5.1.Many System administrators still however don’t know which exact command to be used for this purpose. Infact AIX 5L in background uses only one command which is mkcd, however while using smitty option, there are two possibilities; either you can use “smitty mkcd” or “smitty mkdvd”.

If you use smitty mkcd, you will be indirectly using mkcd command with –d option which will create Rock Ridge format image (a CD-R format image)
However, if you go for smitty mkdvd option (which is usually used for creating backups on DVD cartridges), you will be prompted for two possible format options; one possible format option is UDF format (which is in background use mkcd command with –U option). Other possible option is ISO9660 format (which also uses mkcd command in background but with –L & -d flags).

If you are using DVD cartridges with DVD RAM drive , use smitty mkdvd with UDF format selected, because in that case the space required on disks for creation of temporary filesystems is much less than space required in case of ISO9660 format.
Unfortunately, you'll need extra file system space to create the CD's,
and ISO9660 DVDs. Unlike UDF DVDs, where files can be
written directly to the media, an ISO9660 CD/DVD image must be created
in the file system first, before copying it to CD. The easiest way to work around
this, is to just allow mkcd to create the temporary file systems it needs, and it will remove them after it has finished using them. It will also exclude them from the backup, so you won't end up with mkcd’s created temporary filesystems in your mksysb image. However, in many situations, you don’t have even space for creation of these temporary filesystems on disk. Under these circumstances, it is better to use UDF format rather than IS09660 format.
Temporary filesystems which are created by mkcd command with ISO9660 ( or so called Rock Ridge format) are /mkcd/mksysb_image, /mkcd/cd_fs and /mkcd/cd_images. On the other hand, with UDF format only /mkcd/mksysb_image filesystem is created, thereby taking less space on disk.
Please keep in mind that while you use smitty mkcd option to create backup image on CD-R, total size of these temporary filesystems will not exceed maximum limit which is the size of an individual CD cartridge (1.3 GB maximum). On the other hand, if you use DVD media, this maximum limit may approach 8GB ( which is maximum size possible for any DVD cartridge).

Conclusively we can say that if you are using CD-R cartridges, use smitty mkcd (or mkcd –d command).On the other hand , if you are using DVD RAM cartridges , you can use mkcd –d for CD image format (ISO9660) with –L for large size support ( essentially required for DVD cartridges) or simply use mkcd –U for UDF format.


Copying files on UDF filesystems on DVDs

In some circumstances, system administrators may want to just use DVD RAM cartridges for taking backup of files rather than whole operating system or volume group. For this task, you can simply use copy command. However, before that, you have to create a UDF filesystem on DVD cartridge. Below is a simple shell script which I use in my own environment to automate both tasks. It simply moves an application log files which are older than specified number of days from source filesystem to temporary target directory (or you can create a filesystem for this purpose also) and then from this target filesystem, log files are copied to DVD cartridge using UDF filesystem format. You can however, modify it to moving files directly from disk storage to DVD directly without having a temporary staging filesystem on disk. The shell script is intelligent enough to have a calculation on total size of log files which are to be moved from source filesystem to target filesystem (by your selection of number of days) and then give you a choice to either proceed or simply exit from the script without doing anything.
-----------------------------------------------------------------------
#!/bin/ksh
#Script Name: applogsba.sh
#Script Purpose: To copy older log files to DVD cartridge on AIX

function chk_mnt
{
df | grep "/mnt" >/dev/null
if [[ $? = 0 ]]
then
echo " DVD RAM is still mounted...Can't proceed..."
echo " Please unmount DVD and then reexecute the script"
exit 1
fi
}

#Main Script startup
# First check for mounting status of DVD UDF filesystem
chk_mnt
echo " Please enter the source directory containing application log files..."
read srcdir
echo " Please now enter target filesystem's name in absolute path format "
read trgdir
cd $srcdir
echo " Now please enter the number of days for archiving files ....."
read numbdays
find . -name "*.log" -ctime +$numbdays -exec ls -al {} \; >filelist
cat filelist
echo
echo
echo " Above files will be moved by this selection "
echo
echo
z=`more filelist | awk '{sum=sum + $5};END{ print sum/1048576}'`
echo " Also,you will require $z MB Free in $trgdir to copy specified log files"
echo
echo
echo "\n And these files will use $z MB only on DVD cartridge ,if copied"
echo
echo
echo "please enter y to continue or n to exit from script.........."
read ans
case $ans in
y)
avail=`df -m | grep "$trgdir" | awk ' { print $3} '`
if [ $avail -gt $z ]
then
DATEDR="archive-$(date +%H%M%S"-"%d"-"%B"-"%Y)"
if test -d $DATEDR
then
echo directory already exists.... now proceeding to copy files only
else
mkdir $trgdir/$DATEDR
fi
more filelist | awk ' { print $9 }' > workfile
while read filename
do
echo "Moving $filename to taget filesystem"
mv $filename $trgdir/$DATEDR/
done < workfile
else
echo " You don't have enough space in $trgdir filesystem "
echo "\n Please create enough space in target filesystem"
exit 1
fi
echo " Now please insert DVD RAM cartridge and press enter when ready"
echo "\n WARNING..Data on DVD cartridge will be overwritten by proceeding "
read
lsdev -Cc cdrom | grep "Available" 1>/dev/null
if [[ $? = 0 ]]
then
echo "Please wait .... now creating new UDF filesystem on DVD ..."
sleep 1
udfcreate -d /dev/cd0
if [[ $? = 0 ]]
then
mount -v udfs /dev/cd0 /mnt
cd $trgdir/$DATEDR
echo " Now Copying required log files to DVD...."
echo " Please wait ............................."
sleep 2
cp -pR * /mnt/
echo " Files have been copied... please check by using ls command on /mnt"
exit 0
else
echo " Device not ready....check the media or DVD drive"
exit 1
fi
else
echo " DVD is not available on this system.... .Make it available and retry"
exit 1
fi
;;
n) echo "You have selected to exit from script..nothing will happen...."
exit 1
;;
*) echo invalid choice
exit 1
;;
esac

----------------------------------------------------------

Using Sysback for backups to DVD

Sysback, being powerful tool for backup and recovery tool from IBM provides you greater flexibility while using optical media for backups. For example, with Sysback, you can take backups on every level including filesystems, files & directories, volume group and off course mksysb. Sysback also supports both formats to take backups (ISO9660 as well as UDF format) on DVD & CD-R. Another good feature of Sysback is that it allow you to designate one remote server as CD/DVD server (server having DVD/CD device and enough storage to allow temporary filesystems to be created during DVD/CD-RW based backup operations).
For creating backups on DVD/CD-R using Sysback, follow the following procedure:

Smitty SysbackBackup & Recovery OptionsBackup OptionsCreate a backup to CD/DVDSelect backup format (ISO9660 or UDF) select backup type (which will give you option between full system, volume group, filesystems, files and directories and Logical volumes).

Sysback also provides you an option to write your backup directly to DVD cartridges without any need of creation of temporary work space on disk storage. Additionally, appending of backup data onto existing backup image on DVDs is also possible with Sysback tool.

Summary:
As a matter of fact, every solution has its own pros and cons; same rule applies to use of optical media on pSeries boxes. You can easily use DVDs and CD-R for backups on AIX systems however you have to keep two drawbacks in your mind; first relatively slow speed of backup/restoration operations; second, size limitation for the backup images. On the other hand, these drawbacks are over come by cost effectiveness of any backup solution based on DVD and CD-R media. Choice is off course yours!!!!

No comments:

Post a Comment

 How to Enable Graphical Mode on Red Hat 7 he recommended way to enable graphical mode on RHEL  V7 is to install first following packages # ...