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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Savevg Command? 1

Status
Not open for further replies.

Germo

Technical User
Mar 29, 2004
123
GB
Hi All,

I have a question about the savevg command and was wondering if it is possible to use the savevg command to get the Volume Group infor but not backup the data within that volume group

Currently I use

savevg -i -e -m -f /dev/rmt3.1 volumegroup name

This backs up the data but if there a way to just get the Volume Group information and not the data inside the Volume Group?
All our servers data is backed up using TSM so if I was to rebuild a server from scratch I would like to restore a savevg without any data.

Thanks
 
You could use the exclude file. Create a /etc/exclude.yourvg file. I've never tried it but a * may exclude all files.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Check out the [tt]mkvgdata[/tt] command.

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 
Also found this script on the Xephon site

Code:
Saving volume group information



#!/usr/bin/ksh
#
# Script: save_vg_info.ksh
#
# Author: Steve Diwell - Jedi Technology Ltd.
#
# Date:   June 1999
#
# Aim:    Save the volume group information required to recreate a
#         volume group after a disk crash.
#
# NOTE:
#       To run this script in debug mode type:
#          export DEBUG=yes
#       on the command line before running this script.
#
#       To turn off debug mode type:
#          unset DEBUG
#       on the command line before running this script.
#

#
# Function to display the scripts usage
#
usage()
{
[[ -n ${DEBUG} ]] && set -x
clear

cat <<EOF

This script saves information required to recreate a volume group
after a disaster or disk crash. The volume group information is
stored in the "${SAVEDIR}" directory.

You may specify 'ALL' as the volume group name, in which case the 
script saves information on all volume groups that are currently
on-line.

This script will not create the information on the rootvg 
filesystem.

NOTE: You must be the root user to run this script.

Usage: ${SCRIPT} VolumeGroup|ALL

EOF

exit 1
}

#
# Some commands take a while to run and may produce no output, so
# this function puts a . on the screen every five seconds.
#
progress()
{
while :
do
    echo ".\c"
    sleep 5
done
}

#
# Are we in debug mode?
#
[[ -n ${DEBUG} ]] && set -x
clear

#
# Set environment for the script
#
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:
SCRIPT=`basename ${0}`
SAVEDIR="/var/adm/vgdata"
VG_INPUT=$*

#
# Only root can run the script.
#
[[ `whoami` != "root" ]] && usage

#
# If user input is null or rootvg, display usage.
# If user input is ALL, do all volume groups except rootvg.
#
[[ -z ${VG_INPUT} ]]      && usage
[[ ${VG} = "rootvg" ]]    && usage
[[ ${VG_INPUT} = "ALL" ]] && VG_INPUT=`lsvg -o | grep -v rootvg`

#
# For every volume group listed, save information
#
for VG in `echo ${VG_INPUT}`
do
   echo "\nWorking on volume group ${VG}..."

#
# Let's check the ${VG} is on-line
#
   lsvg -o | grep -q ${VG} || {
      echo "\nThe Volume Group ${VG} is not on-line on this system."
      break
      }

#
# Get all the disks the ${VG} volume group is on.
#
   DISKS=`lsvg -p ${VG} | awk '/active/ { ORS=" "
                          print $1}'`

#
# Create the Exclude file to stop the savevg backing up any files
#
   [[ -f /etc/exclude.${VG} ]] && mv /etc/exclude.${VG} /etc/exclude.${VG}.saved

   echo "/" > /etc/exclude.${VG}

#
# Now, mount all the filesystems in ${VG}, otherwise, savevg will
# miss them!!
#
   echo "\nEnsuring all filesystems in the ${VG} are mounted, please wait."
   progress &
   PID=$!

   lsvg -l ${VG} | awk '/closed/ {
      if ( $2 == "jfs" )
         { if ( system ("mount " $7 ) != 0 )
            print "Mount command failed for " $7
         }
      }'

   echo ""
   kill ${PID} 1>/dev/null 2>&1

#
# Create volume group information
#
   echo "\nCreating the volume group data, please wait..\c"
   progress &
   PID=$!

   mkvgdata -m ${VG} || {
      echo "\nMkvgdata Command Failed for ${VG}"
      kill ${PID}
      exit 1
      }

   echo ""
   kill ${PID} 1>/dev/null 2>&1

#
# Backup the ${VG} data file and put copy in ${SAVEDIR}
#
   [[ ! -d ${SAVEDIR}/${VG} ]] && mkdir -p ${SAVEDIR}/${VG}

   cp /tmp/vgdata/${VG}/${VG}.data ${SAVEDIR}/${VG}/${VG}.data

   echo "" > ${SAVEDIR}/${VG}/${VG}.disks

   for PV in `echo ${DISKS}`
   do
      lspv -l ${PV} >> ${SAVEDIR}/${VG}/${VG}.disks
      echo ""       >> ${SAVEDIR}/${VG}/${VG}.disks
      lspv ${PV}    >> ${SAVEDIR}/${VG}/${VG}.disks
      echo ""       >> ${SAVEDIR}/${VG}/${VG}.disks
   done

#
# Save the volume group structure, which is used by restvg
#
   echo "\nSaving the volume group structure, please wait..."

   savevg -ef ${SAVEDIR}/${VG}.backup ${VG} || {
      echo "Savevg command failed for ${VG}"
      exit 1
      }

   echo "\nInformation required to recreate the ${VG} volume group"
   echo "has been saved in plain text files in \"${SAVEDIR}/${VG}\"."

   echo "\nThe command \"restvg -f ${SAVEDIR}/${VG}.backup\""
   echo "can be used to recreate the volume group.\n"

#
# Put back the original exclude file, if it existed.
#
   if [[ -f /etc/exclude.${VG}.saved ]]
     then
         mv /etc/exclude.${VG}.saved /etc/exclude.${VG}
     else
         rm -f /etc/exclude.${VG}
   fi

#
# Clean up temporary files and directories
#
   [[ -f /tmp/${VG}.backup ]]        && rm -f /tmp/${VG}.backup
   [[ -f /tmp/vgdata/vgdata.files ]] && rm -f /tmp/vgdata/vgdata.files
   [[ -d /tmp/vgdata/${VG} ]]        && rm -fr /tmp/vgdata/${VG}

done            # For the for VG in `echo ${VG_INPUT}`

exit 0

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Thanks people, I'll give it a try when the God's above let me lose on one of our test servers..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top