Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to get all mksysb images 3

Status
Not open for further replies.

xyz786

IS-IT--Management
Apr 5, 2006
45
0
0
US
Hello,
I am trying to get mksysb images of all our servers and save them on our NIM server on daily basis( We have enough space on this).Actually mksysb runs on each server at night 1am.So my plan is to get mksysb images everyday and remove the old ones which were saved on previous day. Any suggestions?

Thanks
 
I assume you saved to an image file similar to the following first.

savevg -v -n -9 / _rootvg.img rootvg

You image can be saved to another server by exporting the filesystem from the server you wish to save to (UNIX equiv to directory sharing).

You then mount the exported file system to each of the servers which requires the image to be saved.

Now that the server performing the back up can see the "NIM" server directory to can either back the image directly to this mount point (and overwriting it) or write a script to
1. save the image
2. copy the script to the new mount point
3. remove the old image
 
schu,
Let me clear what I have been trying to workout. We have around 50 aix servers on which mksysb image runs every night and saves in a their local file system on all the boxes individually. I am trying to get all these individual images on our NIM server (which has enough space to save 50 mksysb images)on daily basis and once the new images stores in NIM server, old images must be deleted. So trying to write a script to accomplish this thing ...by using rsync to all the servers to get the images ...and delete the previuosly saved images.

Thanks
 
Writing the script is easy, and if you use a mount point, you can overwrite the previous image at the same time (however to be safe, the script should rename the old image, save, then on success save the image).

The script to back up to the NIM server would be easy.
The export of filesystem needs to be done once only.

But...
With 50 servers, the concern would be the Disk IO and network traffic to the NIM server.

Do you have fast disks? e.g. IBM Shark, EMC, HDS etc
Do you have a seperate maintenance network for backups.
If you have 50 big servers you may need to add a few more network cards on your NIM server and also seperate your backup servers into different maintenance networks.

If you have the money, a centralized backup solution such as Netback up or EMC legato could be an option, saves all the fuss.
 
Before running this script you have to define NIM clients.

Code:
#!/usr/bin/ksh

IMAGEDIR=/export/images

for CLIENT in $(/usr/sbin/lsnim -t standalone | awk '{print $1}')
do
  
  IMAGE=mksysb_$CLIENT

  FILE=$IMAGEDIR/${CLIENT}_$(date +%Y%m%d)

  LOG=$IMAGEDIR/${CLIENT}_$(date +%Y%m%d).log

  # Delete previous backup, if it exists.
  lsnim $IMAGE >/dev/null 2>&1 && /usr/sbin/nim -o remove -a rm_image=yes $IMAGE

  # Delete logs of previous backups, if any.

  rm -f $IMAGEDIR/${CLIENT}_????????.log

  {
    cat mail_header

    if nim -o define -t mksysb -aserver=master -alocation=$FILE -asource=$CLIENT
 \
      -amk_image=yes -amksysb_flags=eX $IMAGE >$LOG 2>&1
    then
      cat $LOG
      echo "$CLIENT System backup ended successfully at $(date)."
    else
      cat $LOG
      echo "$CLIENT System backup ended UN-SUCCESSFULLY at $(date)."
    fi
  } |
  /usr/sbin/sendmail -t
  
done

I hope this would be useful :)

Regards,
Khalid
 

I make it with Perl an FTP.

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

#!/usr/bin/perl

#
# create an mksysb and put them to the NIM Server
#

use Net::FTP;
# use Net::ping;
# use Env;

chomp ($host = `hostname`);
$in = "/home/mksysb/";
$out = "/NIM/AIX/IMAGES/";
$user = "mksysb";
$password = "mksysb";
$nimhost = "nim";

system ("mksysb -i -X $in$host.mksysb");

$ftp = Net::FTP->new("$nimhost", Debug => 10);
$ftp->login("$user", "$password");
$ftp->binary();
$ftp->put("$in$host.mksysb", "$out$host.mksysb");
$ftp->quit();

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

it works fine.

Regards,
Mikri
 
Hi,
with AIX4.3/AIX5L the creation of mksysb images of NIMclients could be done by defining the appropriate NIM-Resource on the NIMmaster (thru SMIT or by commands i.e. in crontab). That means, the mksysb is automatically written on the NIMmasters filesystem, no need to transfer it afterwards.

# smitty nim_mkres will work like that:
- define mksysb Resource
- NFS export (previously defined) filesystem
- mount this FS on NIMclient
- create (write) mksysb image of NIMclient to this FS
- unexport filesystem on NIMclient
- make NIM mksysb-Resource available on NIMmaster

Result: mksysb-image on NIMmaster as a NIM-Resource, which is available for Reinstallation/Desaster Recovery.,

hth, Martin
 
It's a bit of a 'me too' post but this script makes mksysb backups of all my nim clients on a regular basis and hold two generations (sorry about the lack of comments!)
Code:
#!/usr/bin/perl -w
 
$d_name="/export/mksysb/";
$min_age=12; #no of days until new image reqd
$max_gen=2;  # no of generations to keep
$secs_in_day = 60 * 60 * 24;
$now = int ((time)/($secs_in_day));
(undef,undef,undef,$day,$month,$year,undef,undef,undef)=localtime(time);
$dstring = sprintf "%2.2d%2.2d%2.2d", $year % 100, $month + 1, $day;
$extn = "_[0-9][0-9][0-9][0-9][0-9][0-9]";
 
sub backup;
sub housekeep;
 
HOSTLOOP: for my $hostname (`lsnim -t standalone | cut -f 1 -d ' '`)
  {
  print "Checking $hostname";
  chomp $hostname;
  for ( glob "$d_name$hostname$extn" ) 
    { 
    next HOSTLOOP if ($now - int(((stat($_))[9])/($secs_in_day)) < $min_age );
    }
  backup $hostname;
  my @flist = glob "$d_name$hostname$extn";
  housekeep $hostname if @flist > $max_gen;
  }
 
sub backup 
  {
  my $hostname = shift;
  system "nim -F -o define -t mksysb -a server=master -a mk_image=yes "
    ."-a mksysb_flags=ei -a source=${hostname} "
    ."-a location=$d_name${hostname}_$dstring ${hostname}_$dstring";
  system "rcp ${hostname}:/bosinst.data ${d_name}${hostname}_bosinst_data_$dstring" and return;
  system "nim -o define -t bosinst_data -a server=master ".
    "-a location=${d_name}${hostname}_bosinst_data_$dstring ".
    "${hostname}_bosinst_data_$dstring";
  }
 
sub housekeep 
  {
  my $hostname = shift;
  (glob "$d_name$hostname$extn")[0] =~ /(\d{6})/ and my $date = $1;
  for ( "_", "_bosinst_data_" )
    {
    system "nim -o remove $hostname$_$date";
    system "rm $d_name$hostname$_$date";
    }
  }

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top