script to automate mksysb via nim in AIX 5.3


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to automate mksysb via nim in AIX 5.3
# 1  
Old 12-20-2007
script to automate mksysb via nim in AIX 5.3

#!/bin/ksh
#
# nim_mksysb [-h] [-r] [-n] [-l] [-m 'machines to get mksysb from']
# get mksysb from each client machine specified with -m. If no
# machines specified, get mksysb from ALL machines. -r flag says
# remove oldest existing mksysb for the machines being backed up.
# use -n no_make flag with -r to remove a generation of mksysb,
# without creating a new one.
# Added subdirectory for each nim_machine
# Added help (-h)
# Added list (-l)
# Added MAX_BACKUPS (save up to MAX_BACKUPS, then erase oldest)

### Your customizations begin here ###

# Parent directory for storing mksysb
# Backups will be stored as $MKSYSB_DIR/nim_machine_name/nim_machine_name_date
MKSYSB_DIR=/export/mksysb

# Save up to MAX_BACKUPS per server, then remove oldest (space saving)
# The "-r" option will override and remove the oldest.
MAX_BACKUPS=100

### End customizations ###

# Initialize
remove_old=
machine_list=
no_make=

# Get Command Line Arguments
while getopts hlnrm: option
do
case $option in
h) echo " "
echo "Purpose: automate system backup(s) using NIM"
echo " "
echo "Syntax: `basename $0` [-h] [-r] [-n] [-l] [-m 'machines to get mksysb from']"
echo "\t-h = help"
echo "\t-r = remove the oldest mksysb image"
echo "\t-l = list NIM machines and mksysb images"
echo "\t-n = no backup (used for testing or to remove oldest mksysb)"
echo "\t-m = NIM machine name to backup. Default = backup all"
echo ""
exit;;

l) echo "\n## NIM machines ##"
lsnim -c machines | awk ' !/^master/ { print $1 } '
echo "\n## NIM mksysb Resources ##"
lsnim -t mksysb | awk ' { print $1 }'
echo " "
exit;;

m) machine_list="$OPTARG";;
n) no_make=1;;
r) remove_old=1;;
esac

done

# if machine_list is null at this point, set it to ALL clients
if [ -z "$machine_list" ]; then
machine_list=`lsnim -c machines | awk ' !/master/ { print $1 }'`
fi

# Backup machine(s)
echo "Machine list is $machine_list \n"

for m in $machine_list
do

echo "### Creating NIM mksysb Resource for $m ###"
date

if [ ! -d $MKSYSB_DIR/$m -a -z "$no_make" ]; then
echo "Creating new directory: $MKSYSB_DIR/$m"
mkdir $MKSYSB_DIR/$m
fi

cd $MKSYSB_DIR/$m 2>/dev/null

n_backups=$(ls $m* |wc -l )
if [ ! -z "$remove_old" || $n_backups -ge $MAX_BACKUPS ]; then
oldest=$(ls -lt $m* | tail -1 | awk '{print $9}')
if [ ! -z $oldest ]; then
echo Removing oldest file and nim resource: $oldest
nim -o remove $oldest
/usr/bin/rm $oldest
else
echo "Can not remove oldest file. No files to remove. $oldest"
fi
fi

# if no_make is null, go ahead and make the mksysb
if [ -z "$no_make" ]; then

filename="$m"_`date +%Y%m%d%H%M`

echo New file and nim resource is $filename
echo Machine to backup is $m

echo nim -o define -t mksysb -aserver=master -amk_image=yes \
-alocation=$MKSYSB_DIR/$m/$filename \
-asource=$m $filename

time nim -o define -t mksysb -aserver=master -amk_image=yes \
-alocation=$MKSYSB_DIR/$m/$filename \
-asource=$m $filename

else
echo "Script invoked with no_make option. Backup of $m was not made."
fi
echo "-----"

done

=======================================
OUTPUT generated from the above script
=======================================

### Creating NIM mksysb Resource for aixlib1 ###
Thu Dec 20 16:28:31 CST 2007
Creating new directory: /export/mksysb/aixlib1
ls: 0653-341 The file aixlib1* does not exist.
./mksysb2.sh[86]: test: 0403-021 A ] character is missing.
./mksysb2.sh[86]: 0: not found.
New file and nim resource is aixlib1_200712201628
Machine to backup is aixlib1


The above script automates system backup via NIM on AIX 5.3 and runs OK except that it gives the above errors (character is missing, 0: not found) , looks like I'm overlooking something here, any help is very much appreciated. Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

VIOS backupios -mksysb - does it need to be served by a NIM server ?

working through VIOS backup options. Generally, we store mksysb's on a server and then NFS mount them from it to copy to a VIO optical library, etc. In the case of a VIO backup, I see the -mksysb option to backupios and understand that it doesn't include the NIM resources in the backup. ... (3 Replies)
Discussion started by: maraixadm
3 Replies

2. AIX

mksysb using NIM

I am implementing mksysb backups using NIM. I am using nimsh as client communication and mksysb backup are working fine, but this requires remote logon to be enabled for root. Any thoughts on how can I implement mksysb backups using NIM without enabling remote logon for "root" ? (1 Reply)
Discussion started by: mk8570
1 Replies

3. AIX

mksysb restoration using NIM

Hi, I just want to ask whether anyone has experience on restoring mksysb backup in NIM. We have taken the mksysb backup and the SPOT has been configured on NIM also. I just want to know the checkpoints before doing this. Is there any checkpoints we need to do? Do we need to unmirrorvg? This... (12 Replies)
Discussion started by: depam
12 Replies

4. AIX

AIX 5L nim mksysb command

Hi All, Please excuse the possibly naive question but I'm trying to clone/install a new AIX 5.3 LPAR on a p570 from a mksysb image file using nim. Has anyone done this before and if so, what would the exact command look like? Does it even remotely resemble something like nim -o... (1 Reply)
Discussion started by: combustables
1 Replies

5. AIX

how to create a package from mksysb via nim ?

Hello, I need to install "bos.adt.libm 5.3.0.0" on a server (AIX5.3 power 5). How to install it from a nim mksysb of an another partition ? Thank you (3 Replies)
Discussion started by: astjen
3 Replies

6. AIX

nim mksysb buffer overflow error

Hi, I am trying to backup a system ("client") through a slow network using "nim mksysb" on a nim server ("master") The backup starts, but doesn't success. Thanks if you can help me to resolve this problem : Creating information file (/image.data) for rootvg... Creating list of files to... (2 Replies)
Discussion started by: astjen
2 Replies

7. AIX

NIM client mksysb restore

Can a NIM client mksysb restore be performed via NIM (smitty nim) without the NIM client machine having the NIM server's IP and hostname in its /etc/hosts file? (10 Replies)
Discussion started by: kah00na
10 Replies

8. UNIX for Dummies Questions & Answers

nim mksysb - 0042-124 c_ch_nfsexp error

Hello, help me please. I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? : Command : failed stdout: yes stderr: no +---------------------------------------------------------------------+ System Backup Image Space Information (Sizes are displayed in... (4 Replies)
Discussion started by: astjen
4 Replies

9. UNIX for Advanced & Expert Users

NIM - mksysb of remote server

Hi, I'm trying to use my NIM server to get a mksysb of an lpar on another machine on my network. I'm trying to define a resource through smitty and i've entered the resource name, Server of resource & location of resource, they are as follows Resource Name : gmt_fail_mksysb Server of... (1 Reply)
Discussion started by: KeesH
1 Replies

10. AIX

NIM mksysb recovery

I have multiple LPARS on p650 with mix of AIX5.2 and AIX5.1 with different rml level My understanding is creating mksysb nim on NIM server is for new installation of LPARS Then; How do I do mksysb backup on existing lpars for recovery purpose or how do I do all mksysb to a NFS mounted Filesystem... (1 Reply)
Discussion started by: melindaj
1 Replies
Login or Register to Ask a Question