Script to recreate a volume group with new PVIDs
Posted by steve on 02 Jun 2012 in Scripts and One Liners
#!/usr/bin/ksh
# Script to re-create volume groups from flash copies with new PVID's.
typeset -Z2 COUNT=1
while lspv | grep -e hdisk -e vpath | grep None | head -1 | grep -q None
do
DISK=$( lspv | grep -e hdisk -e vpath | grep None | head -1 )
ALL_PVIDS=$( lqueryvg -Pp ${DISK} | awk '{ print $1 }' )
TEST=$( print ${ALL_PVIDS} | sed 's; ; -e ;g' )
ALL_DISKS=$( lspv | grep -e ${TEST} | awk '{ print $1 }' )
recreatevg -L / -Y NA -y new${COUNT}vg ${ALL_DISKS}
(( COUNT = COUNT + 1 ))
done