DISCLAIMER : Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility.If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.
Using savevg on AIX to save time creating filesystems, LV's and volume groups
If you ever need to build multiple servers that will all have the same
volume groups, logical volumes, and filesystems you can use "savevg" and
"restvg" to save yourself a bunch of time and duplicated work.
This also works if you are ever asked to build a new server that should be setup with the same VG/LV/FS's as an older server.
You start by setting up one of the servers with the volume groups,
logical volumes, and filesystems that you will need. Next you can use
the "savevg -r" command to backup just the volume group/LV/Filesystem
structure information. With the "-r" flag it doesn't backup any data in
the filesystems, which makes it quick and the backup file very small.
In this example we want to duplicate the "appvg" structure on to another server:
# lsvg -l appvg
appvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv02 jfs2log 1 1 1 open/syncd N/A
applv05 jfs2 52 52 4 open/syncd /app5
fslv05 jfs2 25 50 2 open/syncd /app2
loglv03 jfslog 1 1 1 closed/syncd N/A
#
# savevg -r -f /appvg.savevg appvg
Creating information file for volume group appv g... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ..
Backing up user Volume Group information files only.
Creating list of files to back up.
Backing up 6 files
6 of 6 files (100%)
0512-038 savevg: Backup Completed Successfully.
Next you copy the "/appvg.savevg" file on to all the servers that you
want to setup the VG/LV/FS's on. You can use something like "scp" or
"sftp" or another protocol to transfer the file.
On the other servers, you run "restvg" to restore the VG/LV/FS structures from the file:
# restvg -r -f /appvg.savevg hdisk1 hdisk2
Will create the Volume Group: appvg
Target Disks: hdisk1 hdisk2
Allocation Policy:
Shrink Filesystems: no
Preserve Physical Partitions for each Logical Volume: no
Enter y to continue: y
0516-1254 /usr/sbin/mkvg: Changing the PVID in the ODM.
appvg
loglv02
applv05
fslv05
loglv03
#
# lsvg -l appvg
appvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv02 jfs2log 1 1 1 open/syncd N/A
applv05 jfs2 52 52 2 open/syncd /app5
fslv05 jfs2 25 50 2 open/syncd /app2
loglv03 jfslog 1 1 1 closed/syncd N/A
As you can see the "restvg -r" command restored the volume group,
logical volumes, and filesystems, and even mounts the filesystems for
you! Note that the fslv05 LV was mirrored before on the original server
and when restored it is still mirrored. The original volume group on
the source server was on 4 hdisks, but on the destination server only
had 2 hdisks. But this isn't a problem, restvg is able to take care of
it as long as you have enough disks to accommodate the mirroring and
enough total space for all the logical volumes. You can even use the
"-s" flag on restvg to attempt to shrink the filesystems if the
destination hdisks aren't large enough to hold all the original LV's.