#!/bin/bash # # Program: Veritas configuration archiver # # Author: Matty < matty91 at gmail dot com > # # Current Version: 1.0 # # Revision History: # Version 1.0 # - Original release # # Last Updated: 11-14-2006 # # License: # 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. # # Purpose: vxvmconfigbackup can be used to backup disk group and # volume configuratio data. This data can be used during # a recovery scenario to restore a volume or disk group # configuration. # Create a default environment PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH # Global variables DATE=`date "+%m-%d-%Y-%M%S"` DIRECTORY="/etc/dgbackups" ### Function to call to print usage information usage() { echo "Usage: $0 [ -d directory ]" echo " -d directory : The directory to store configuration backups" echo " -g disk group : Disk group to backup" echo " -v volume : Volume to backup" } ### Parse the options passed on the command line while getopts a:d:g:v: option do case "${option}" in d) DIRECTORY=${OPTARG};; g) DG=${OPTARG};; v) VOLUME=${OPTARG};; \?) usage exit 1;; esac done ### Check to make sure a directory is available to store the backups if [ ! -d ${DIRECTORY} ] then echo "${DIRECTORY} does not exist" exit 1 fi ### Check to make sure vxdg and vxprint are available if [ ! -f "/usr/sbin/vxdg" ] && [ ! -f "/usr/sbin/vxprint" ] then echo "Cannot find vxdg or vxprint in /usr/sbin" exit 1 fi #### Backup a volume if [ "${VOLUME}" != "" ] && [ "${DG}" != "" ] then echo "Backing up volume ${VOLUME} to ${DIRECTORY}/${DG}.${VOLUME}.${DATE}" /usr/sbin/vxprint -hmQq ${VOLUME} > ${DIRECTORY}/${DG}.${VOLUME}.${DATE} ### Backup a specific disk group elif [ "${VOLUME}" = "" ] && [ "${DG}" != "" ] then echo "Backing up disk group ${DG} to ${DIRECTORY}/${DG}.${DATE}" /usr/sbin/vxprint -g ${DG} -hmQq > ${DIRECTORY}/${DG}.${DATE} #### Backup all disk group configurations by default else for DG in `/usr/sbin/vxdg -q list | awk '{print $1}'` do echo "Backing up the disk group configuration for ${DG} to ${DIRECTORY}/${DG}.${DATE}" /usr/sbin/vxprint -g ${DG} -hmQq > ${DIRECTORY}/${DG}.${DATE} done fi exit 0