Create a LVM Snapshot partition

I’m modifing my Groupwise backup script to make use of LVM snapshot so the downtime off my Groupwise system is reduced. Like many other, I prefer a off-line backup of my Groupwise system.

The scripts is very simple:

  • Groupwise is shutdown
  • TAR makes a backup of my Groupwise directory including all Groupwise config files. The filename of the TAR file is extended with a date of the backup.
  • Groupwise is started
  • Backup file is moved to a NFS share on a different server and checked for errors
  • Backupfile older than 14 day’s are removed

The disadvantages off this script is that the bigger the Groupwise database gets, the longer it’s down!

So by making use of LVM snapshots I hope to reduce the down time.

So how to create a LVM snapshot? First we’re going to create the LVM volume for Groupwise.
First we have to create a LVM partition. I’m going to use fdisk for this:

# fdisk /dev/sdb
Press n for a new partition
Press P for a Primary partition
Press 1 for the first partition
Give the first block and the last block for the partition
Press t in the main menu to change the partition’ system id.
Give 8e for LVM
Press w to write the partition table to disk

Ok,  now we have a empty LVM partition. Now where going to create a LVM Physical Volume.

# pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created

Create a LVM Volume Group called Groupwise.

# vgcreate VG_Groupwise /dev/sdb1
Volume Group “VG_Groupwise” succesfully created

You can check with vgdisplay to verify the volume group

Next where going to create a Logical Volume of 10G called LV_Groupwise

# lvcreate -L10G -nLV_Groupwise VG_Groupwise
Logical volume “LV_Groupwise” created

And final add a filesystem to the Logical Volume. I’m using EXT3 for Groupwise.

# mkfs.ext3 /dev/VG_Groupwise/LV_Groupwise

I will spare you the detail of the output.
If the filesytem is created you can mount the Logical Volume on a mount point. I’m using /grpwise.

# mount -t ext3 /dev/VG_Groupwise/LV_Groupwise /grpwise

To make sure that the LVM volume is mounted a boot time, make sure you add the line to /etc/fstab

Ok, now we have a working LVM volume. So how are we going to create a snapshot of this volume?
Make sure that the LVM Volume Group has some free space to keep track of the changes made to the original Volume Group will the snapshot is active. How much? This depends on the amount of changes to you Groupwise system.
The snapshot will be mounted on /gwbackup.

# lvcreate -L1G -s -n GWBackup /dev/VG_Groupwise/LV_Groupwise
Logical volume “GWBackup” created

# mount /dev/VG_Groupwise/GWBackup /gwbackup

Now, we can make a backup of the Groupwise database.
After the backup unmount the volume and remove the snaphot.

# umount /gwbackup

# lvremove /dev/VG_Groupwise/GWBackup
Logical Volume “GWBackup” removed

What really is nice that while the snapshot is active, you can use this snapshot for a Restore Area for your Groupwise system. Nice!

About Michael
Michael Wilmsen is a VMware training/consultant (no specific order) with more than 15 years in the IT industry. Main focus is VMware vSphere, Horizon View and Site Recovery Manager with a deepdive to performance. Michael is VCDX 210, VCAP 4/5 certified, has been rewarded with the vExpert title from 2011, is a PernixPro, Nutanix Tech Champion and a Nutanix Platform Professional.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

You must be logged in to post a comment.