<p>This process uses the savevg command to backup the VG structure information. I used to to this by first excluding any filesystems from the backup by populating the /etc/exclude.vg files with all the filesystems, but IBM introducted the &#8220;-r&#8221; flag that does the same thing.  We purposely exclude rootvg from this because all the rootvg filesysetems will be in the mksysb backup.</p>
<pre><code>#!/bin/perl
#
# Author: Patrick Vaughan - http://patrickv.info
#
# Purpose:
# Saves VG structure to files for easy recovery
#
# Restore with:
# restvg -f /vgdata/savevg.VGNAME DISKNAME
#
$test=1;
$DEBUG=0;
$" = "";
$GREP = "/usr/bin/grep";
$LSVG = "/usr/sbin/lsvg";
$EXCLUDE_VGS = "rootvg"; # VGs to exclude in a REGEXP
$VGDATA_DIR = "/vgdata";
if ( ! -d "$VGDATA_DIR" ) {
         mkdir("$VGDATA_DIR") || die("Could not create directory $VGDATA_DIR: $@ \n");
}
@VGS = grep(!/$EXCLUDE_VGS/, `$LSVG -o`);
for ( @VGS ) {
         chomp;
         $vg = $_;
#       exclude files are no longer necessary since the -r flag was introduced
#       if ( -f "/etc/exclude.$vg" ) {
#               unlink("/etc/exclude.$vg") || die("Could not remove file /etc/exclude.$vg: $@\n");
#       }
#       (@LVs) = grep(/^\//, split(/\s+/, `$LSVG -l $vg`, -1 ) );
#       open(EXCLUDE_VG, "&gt;/etc/exclude.$vg") or die("Could not create file /etc/exclude.$vg: $@\n");
#       for (@LVs) {
#               # populate /etc/exclude.vg with ^./filesystem/ because we don't want the data
#               print EXCLUDE_VG ("^.$_/\n");
#       }
#       close(EXCLUDE_VG);
#       undef(@LVs);

         print "savevg of $vg to $VGDATA_DIR/savevg.$vg starting.\n";
         system(`savevg -irf $VGDATA_DIR/savevg.$vg $vg`);
         print "savevg of $vg to $VGDATA_DIR/savevg.$vg complete.\n";

# We're done with the exclude files, lets delete them
#       unlink("/etc/exclude.$vg") || die("Could not remove file /etc/exclude.$vg: $@\n");
}</pre>
<p></code></p>
<p>This will create one file in the directory /vgdata for each volume group on the system.  You can then use the restvg -f /vgdata/savevg.xxx to restore the VG data.  Check the restvg man page for more information.</p>
<p>To get information about the backup run:</p>
<pre><code>restvg -l -f savevg.X
VOLUME GROUP:           sharedGvg
BACKUP DATE/TIME:       Tue May 29 09:33:56 EDT 2007
UNAME INFO:             AIX cnpg 3 5 002680EF4C00
BACKUP OSLEVEL:         5.3.0.50
MAINTENANCE LEVEL:      5300-05
BACKUP SIZE (MB):       15008
SHRINK SIZE (MB):       1727
VG DATA ONLY:           no
sharedGvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
shareGlv            jfs2       938   938   1    open/syncd    /shared</code></pre>
<p>You can see the VG size and LV info to make decisions on restoring the VG.</p>
{"id":547,"date":"2010-09-10T13:09:01","date_gmt":"2010-09-10T17:09:01","guid":{"rendered":"http:\/\/patrickv.info\/wordpress\/?p=547"},"modified":"2010-09-10T13:09:01","modified_gmt":"2010-09-10T17:09:01","slug":"saving-the-structure-of-a-vg","status":"publish","type":"post","link":"https:\/\/rootuser.ninja\/index.php\/2010\/09\/10\/saving-the-structure-of-a-vg\/","title":{"rendered":"Saving The Structure Of A VG"},"content":{"rendered":"<p>This process uses the savevg command to backup the VG structure information. I used to to this by first excluding any filesystems from the backup by populating the \/etc\/exclude.vg files with all the filesystems, but IBM introducted the &#8220;-r&#8221; flag that does the same thing.\u00a0 We purposely exclude rootvg from this because all the rootvg filesysetems will be in the mksysb backup.<\/p>\n<pre><code>#!\/bin\/perl\n#\n# Author: Patrick Vaughan - http:\/\/patrickv.info\n#\n# Purpose:\n# Saves VG structure to files for easy recovery\n#\n# Restore with:\n# restvg -f \/vgdata\/savevg.VGNAME DISKNAME\n#\n$test=1;\n$DEBUG=0;\n$\" = \"\";\n$GREP = \"\/usr\/bin\/grep\";\n$LSVG = \"\/usr\/sbin\/lsvg\";\n$EXCLUDE_VGS = \"rootvg\"; # VGs to exclude in a REGEXP\n$VGDATA_DIR = \"\/vgdata\";\nif ( ! -d \"$VGDATA_DIR\" ) {\n         mkdir(\"$VGDATA_DIR\") || die(\"Could not create directory $VGDATA_DIR: $@ \\n\");\n}\n@VGS = grep(!\/$EXCLUDE_VGS\/, `$LSVG -o`);\nfor ( @VGS ) {\n         chomp;\n         $vg = $_;\n#       exclude files are no longer necessary since the -r flag was introduced\n# \u00a0 \u00a0 \u00a0 if ( -f \"\/etc\/exclude.$vg\" ) {\n# \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 unlink(\"\/etc\/exclude.$vg\") || die(\"Could not remove file \/etc\/exclude.$vg: $@\\n\");\n# \u00a0 \u00a0 \u00a0 }\n# \u00a0 \u00a0 \u00a0 (@LVs) = grep(\/^\\\/\/, split(\/\\s+\/, `$LSVG -l $vg`, -1 ) );\n# \u00a0 \u00a0 \u00a0 open(EXCLUDE_VG, \"&gt;\/etc\/exclude.$vg\") or die(\"Could not create file \/etc\/exclude.$vg: $@\\n\");\n# \u00a0 \u00a0 \u00a0 for (@LVs) {\n# \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # populate \/etc\/exclude.vg with ^.\/filesystem\/ because we don't want the data\n# \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 print EXCLUDE_VG (\"^.$_\/\\n\");\n# \u00a0 \u00a0 \u00a0 }\n# \u00a0 \u00a0 \u00a0 close(EXCLUDE_VG);\n# \u00a0 \u00a0 \u00a0 undef(@LVs);\n\n         print \"savevg of $vg to $VGDATA_DIR\/savevg.$vg starting.\\n\";\n         system(`savevg -irf $VGDATA_DIR\/savevg.$vg $vg`);\n         print \"savevg of $vg to $VGDATA_DIR\/savevg.$vg complete.\\n\";\n\n# We're done with the exclude files, lets delete them\n# \u00a0 \u00a0 \u00a0 unlink(\"\/etc\/exclude.$vg\") || die(\"Could not remove file \/etc\/exclude.$vg: $@\\n\");\n}<\/pre>\n<p><\/code><\/p>\n<p>This will create one file in the directory \/vgdata for each volume group on the system.\u00a0 You can then use the restvg -f \/vgdata\/savevg.xxx to restore the VG data.\u00a0 Check the restvg man page for more information.<\/p>\n<p>To get information about the backup run:<\/p>\n<pre><code>restvg -l -f savevg.X\nVOLUME GROUP: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sharedGvg\nBACKUP DATE\/TIME:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Tue May 29 09:33:56 EDT 2007\nUNAME INFO:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AIX cnpg 3 5 002680EF4C00\nBACKUP OSLEVEL:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5.3.0.50\nMAINTENANCE LEVEL:\u00a0\u00a0\u00a0\u00a0\u00a0 5300-05\nBACKUP SIZE (MB):\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 15008\nSHRINK SIZE (MB):\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1727\nVG DATA ONLY:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 no\nsharedGvg:\nLV NAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LPs\u00a0\u00a0 PPs\u00a0\u00a0 PVs\u00a0 LV STATE\u00a0\u00a0\u00a0\u00a0\u00a0 MOUNT POINT\nshareGlv\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 jfs2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 938\u00a0\u00a0 938\u00a0\u00a0 1\u00a0\u00a0\u00a0 open\/syncd\u00a0\u00a0\u00a0 \/shared<\/code><\/pre>\n<p>You can see the VG size and LV info to make decisions on restoring the VG.<\/p>\n","protected":false},"excerpt":{"rendered":null,"protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[],"class_list":["post-547","post","type-post","status-publish","format-standard","hentry","category-aix-notes","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/posts\/547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/comments?post=547"}],"version-history":[{"count":0,"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/posts\/547\/revisions"}],"wp:attachment":[{"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/media?parent=547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/categories?post=547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rootuser.ninja\/index.php\/wp-json\/wp\/v2\/tags?post=547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}