Use vgcfgbackup and vgcfgrestore to back up metadata on LVM - Open Source - Techguide

Use vgcfgbackup and vgcfgrestore to back up metadata on LVM

 

Summary

Scott Reeves shows how to use two handy commands to back up and restore volume group metadata on LVM.

Events

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

Two of the useful commands provided as part of Logical Volume Manager (LVM) is vgcfgbackup and vgcfgrestore. This command allows you to back up the metadata of a volume group.

This may not seem like much, but there are a few scenarios where having a backup of the volume group metadata can save some time and maybe sanity as well. A cautionary note: vgcfgbackup backs up the volume group metadata only. It does not back up the data on the logical volumes.

Running vgcfgbackup is straightforward. The option -f specifies the file to use, otherwise, the default location is in /etc/lvm/backup. It is best to back the directory /etc/lvm up to a location that is backed up to tape or to another server. If no volume group is specified, then vgcfgbackup will back up all volume groups on the system. The command string to use is vgcfgbackup -f <filename> <volume group name>.  An example is as follows.

root@gudaring:/etc/lvm# vgcfgbackup -f /tmp/vg01 vg01
  Volume group "vg01" successfully backed up.
root@gudaring:/etc/lvm#

The output of the file generated in /etc/lvm/backup is shown below.

vg01 {
      id = "K6a5ta-LVA1-PEx0-Dvic-3gTt-ZdTV-Rq6oJZ"
      seqno = 42
      status = ["RESIZEABLE", "READ", "WRITE"]
      flags = []
      extent_size = 8192            # 4 Megabytes
      max_lv = 0
      max_pv = 0
      physical_volumes {
            pv0 {
                  id = "UX9v6y-kF2k-3O98-7O1j-7AKd-4dAS-9KFHyZ"
                  device = "/dev/sda6"    # Hint only
                  status = ["ALLOCATABLE"]
                  flags = []
                  dev_size = 29216768     # 13.9316 Gigabytes
                  pe_start = 384
                  pe_count = 3566   # 13.9297 Gigabytes
            }
      }
      logical_volumes {
            home {
                  id = "q9sZOd-O1N2-xn0W-8EVY-13L2-ln7d-UhcB8f"
                  status = ["READ", "WRITE", "VISIBLE"]
                  flags = []
                  segment_count = 1
                  segment1 {
                        start_extent = 0
                        extent_count = 2560     # 10 Gigabytes
                        type = "striped"
                        stripe_count = 1  # linear
                        stripes = [
                              "pv0", 0
                        ]
                  }
            }
            lvol0 {
                  id = "JPavYt-GmNX-Ve8b-v6NW-xePP-25iB-QdlOOX"
                  status = ["READ", "WRITE", "VISIBLE"]
                  flags = []
                  segment_count = 1
                  segment1 {
                        start_extent = 0
                        extent_count = 512      # 2 Gigabytes
                        type = "striped"
                        stripe_count = 1  # linear
                        stripes = [
                              "pv0", 2560
                        ]
                  }
            }
      }
}

There are a few sections here. The volume group section in this case contains the physical volume information and the logical volume information. Further information can be noted. The extent size for the volume group is shown. In the physical_volumes section the size of the device is shown. Under the logical_volumes section, information about the logical volumes in the volume group are shown. This includes which physical volumes are used by the logical volumes.

The practical step is using vgcfgrestore to recover the metadata. The options used are similar to those used for vgcfgbackup. The -f option can be used to specify a filename. One of the nice aspects of vgcfgrestore is that it can recover up to ten iterations back. The /etc/lvm/archive directory has the last ten configuration files.

To list which point you want to restore from, you can run vgcfgrestore with the -l option and the volume group. In this case, the command string used is vgcfgrestore -l vg01.  This will list the last 10 restore points. The output is similar to below (only the last couple of lines are shown, for brevity).

File:       /etc/lvm/archive/vg01_00043.vg
  VG name:        vg01
  Description:    Created *before* executing 'vgscan'
  Backup Time:    Mon Nov 21 22:25:23 2011
File:       /etc/lvm/archive/vg01_00044.vg
  VG name:        vg01
  Description:    Created *before* executing 'vgscan'
  Backup Time:    Mon Nov 21 22:25:23 2011
File:       /etc/lvm/backup/vg01
  VG name:        vg01
  Description:    Created *after* executing 'vgscan'
  Backup Time:    Mon Nov 21 22:25:23 2011

The output lists the full pathname of each backup file, along with a date stamp. Once you know which file you need to roll back to it is a matter of running the command string vgcfgrestore -f <filename>. For this example, we use the last filename.

root@gudaring:/etc/lvm# vgcfgrestore -f /etc/lvm/backup/vg01 vg01
  Restored volume group vg01
root@gudaring:/etc/lvm#

The output indicates successful rollback.

The commands vgcfgbackup and vgcfgrestore are useful commands to use when you need to restore volume group metadata, as you may want to do if you have a failed disk in an array group, or a similar scenario. You can also use vgcfgrestore to restore an earlier version of the metadata.

Scott Reeves has been working in IT for 15 years, mostly in System Administration roles.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

Malaysia organizations don't realize severity of cyberattacks http://t.co/PUCv68Rd

News: Radio Costa Rica by EnjoyIT 1.0: Radio Costa Rica allows you to listen to a great var... http://t.co/BLzVT5As http://t.co/1Dhcy6ki

The key for mobile operators is identifying the applications that are popular with subscribers on their network. They can then work partn...

1 hour ago by camcullen on Experience trumps content in apps monetization

Experience trumps content in apps monetization | ZDNet http://t.co/gBXcjbGd

Experience trumps content in apps monetization - ZDNet Asia News: "What we are doing currently is not to monetiz... http://t.co/S2EZtd8m

Malaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said at the Sec... http://t.co/bgVlOBvx

#security Malaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said ... http://t.co/hkFb4zrI

Malaysia organizations don't realize severity of cyberattacks http://t.co/EEEmRM3j via @zdnetasia

Malaysia organizations don't realize severity of cyberattacks - ZDNet Asia News http://t.co/YpNMYgb5

Malaysia organizations don't realize severity of cyberattacks http://t.co/FFems54Q

China solar cell makers seek Taiwan partnerships http://t.co/p5Hh7kJD

Big data acquisitions pave way to fast, effective innovation http://t.co/hdiEfBsz via @zdnetasia

Integration, focused investments to propel Windows Phone: By Kevin Kwang , ZDNet Asia on May 23, 2012 (2 hours a... http://t.co/E7tsZbHJ

Integration, focused investments to propel Windows Phone http://t.co/u9TqjQ8C

ZDNet Asia IT Salary Benchmark 2012 http://t.co/rVwYlV7H

AsiaClassifiedToday. Integration, focused investments to propel Windows Phone - ZDNet Asia: S... http://t.co/47tdjZyG #asia #google #biz

So much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...

1 day ago by y15822137359 on 5 SaaS adoption speed bumps to avoid

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

2 days ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

3 days ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

5 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

5 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

5 days ago by wykoong on Drop the egos, copy ideas, then innovate