Cloning a Volume Group [hpux]

Often I am asked to clone an entire Volume Group including all of the logical volumes contained.  This can be a tedius task when the Volume Group contains a hundred or so logical volumes.

This request is often used for testing software releases, deployments, etc.

I’ve use this script at least a dozen times per month, and haven’t really fine tuned it, or improved it at all.  I still create the volume group manually, and add the physical disks.

# Loop through each logical volume name (They all should start with l),
# get the size, and then create in the new VG.

for i in `ls -1 /dev/vgORIGINALVG/l*`
do
MB=`lvdisplay /dev/vgORIGINALVG/$i | grep “LV Size” | cut -c23-40`
lvcreate -n $i -L $MB /dev/vgNEWVG
done

Real basic, but saves quit a bit of time.  I am merely keeping everything default, and am not taking into consideration any special settings.  Again, these are generally used for testing, and then removed — at least in my environment. So it’s not really a true “clone”.

I’m sure there are countless otherways to accomplish this, and maybe even an easier way, but I whipped this up one day when I had a request to clone 3 or 4 VG’s.

This might work on other LVM systems with some tweaking.

Post a Comment

Your email is never shared. Required fields are marked *

*
*