Script to make mksysb backup from NIM to LPAR

Make mksysb backup for your rootvg to NIM is very important. It can save your life sometimes 🙂

This simple script is executed on NIM side and it make the mksysb backup image of your LPAR. ALso it will create lpp_sources resource on the NIM server with the name MKSYSB_lpar1. Please, see at bottom an example. Put it on crontab if you want.

The code is this script (makemksysb.ksh):

Remember to:
– check connection between NIM-LPAR
– check free space on /PATH_TO_MKSYSB_IMAGES/
– sometimes it’s good to restart nfsd on nim server (stopsrc -g nfs;startsrc -g nfs)

#!/usr/bin/ksh
# Copyright (C) 2012 Israel Garcia iga3725 @ yahoo.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
alerta () {
echo
echo "COMMUNICATION NIM-LPAR: There's no connection between NIM and LPAR $1. Check configuration."
echo
exit 128
}
# $1 is the name of lpar nim's (machine resource)
namelpar=$1

# Check if there's another mksysb already running for this lpar.
count=`ps -ef |grep "makemksysb $1" |grep -v grep |wc -l |tr -d ' '`
if  [[ $count > 1 ]] ;then ( exit 127 )
fi

# Reset the spot resource, if exists, for this lpar
nim -o reset spot$1
# Removing spot resource, if exists, for this lpar
nim -o remove spot$1
# Removing  old mksysb resource, if exists, for this lpar
nim -o remove -a rm_image=yes MKSYSB_$1
# make mksysb
nim -o define -t mksysb -F -a server=master -a location=/PATH_TO_MKSYSB_IMAGES/$1.img -a mk_image=yes -a source=$1 -a mksysb_flags=-p -a mksysb_flags=-X MKSYSB_$1
#

See an example. We’re going to make mksysb for lpar1 LPAR.

[root@nim:/usr/local/bin] sh makemksysb2 lpar1
0042-053 nim: there is no NIM object named "lpar1"
0042-053 nim: there is no NIM object named "lpar1"
0042-053 nim: there is no NIM object named "MKSYSB_lpar1"

+---------------------------------------------------------------------+
                System Backup Image Space Information
              (Sizes are displayed in 1024-byte blocks.)
+---------------------------------------------------------------------+

Required = 23170929 (22628 MB)    Available = 577940232 (564395 MB)

Creating information file (/image.data) for rootvg.

Creating list of files to back up.
.
29287 of 185841 files (15%)..............................
48010 of 185841 files (25%)..............................
52080 of 185841 files (28%)..............................
68196 of 185841 files (36%)..............................
87143 of 185841 files (46%)..............................
101827 of 185841 files (54%)..............................
125365 of 185841 files (67%)..............................
147522 of 185841 files (79%)..............................
163660 of 185841 files (88%).........................
185841 of 185841 files (100%)
0512-038 savevg: Backup Completed Successfully.

Once it has finished, check mksysb resource on NIM:

[root@nim:] lsnim -l MKSYSB_lpar1
MKSYSB_lpar1:
   class         = resources
   type          = mksysb
   arch          = power
   Rstate        = ready for use
   prev_state    = unavailable for use
   location      = /LPAR_MKSYSB/lpar1.img
   version       = 6
   release       = 1
   mod           = 9
   oslevel_r     = 6100-09
   alloc_count   = 0
   server        = master
   creation_date = Fri Oct 24 16:22:12 2014
   source_image  = lpar1

Just thanks if the post was helpful 🙂

Advertisements

About igalvarez

More than 20 years experiences on IT industry. 20+ years in Unix experience : IBM-AIX, HMC/SDMC/IVM, SVC, Protectier, PureFlex Systems, VIOservers, IBM Bladecenters, IBM System Power, RedHat Linux, SuSE Linux, Debian/Ubuntu Linux. Solaris, SCO Unix, Tru64 Unix, Linux Virtualization: XEN, KVM, databases sb2, oracle, postgreSQL, Find more information here: http://en.gravatar.com/igalvarez
This entry was posted in AIX, NIM and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s