Recreating Veritas configurations with vxmake

Last year I wrote an article titled Veritas Volume Manager Recovery Features for SysAdmin magazine. In the article I described how to backup a Veritas configuration to a file with vxconfigbackup, and how to restore it with vxconfigrestore. One thing I didn’t touch on was selectively restoring individual volume configurations. This is easy to do, and I wrote the vxvmconfigbackup shell script to simplify capturing the data needed to restore a single Veritas Volume Manager volume. To illustrate just how easy this is, I added three disk drives to a disk group, and then created three volumes (datavol01, datavol02, datavol03). Here is the layout:

$ vxprint -hft

Disk group: datadg

DG NAME         NCONFIG      NLOG     MINORS   GROUP-ID
ST NAME         STATE        DM_CNT   SPARE_CNT         APPVOL_CNT
DM NAME         DEVICE       TYPE     PRIVLEN  PUBLEN   STATE
RV NAME         RLINK_CNT    KSTATE   STATE    PRIMARY  DATAVOLS  SRL
RL NAME         RVG          KSTATE   STATE    REM_HOST REM_DG    REM_RLNK
CO NAME         CACHEVOL     KSTATE   STATE
VT NAME         NVOLUME      KSTATE   STATE
V  NAME         RVG/VSET/CO  KSTATE   STATE    LENGTH   READPOL   PREFPLEX UTYPE
PL NAME         VOLUME       KSTATE   STATE    LENGTH   LAYOUT    NCOL/WID MODE
SD NAME         PLEX         DISK     DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
SV NAME         PLEX         VOLNAME  NVOLLAYR LENGTH   [COL/]OFF AM/NM    MODE
SC NAME         PLEX         CACHE    DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
DC NAME         PARENTVOL    LOGVOL
SP NAME         SNAPVOL      DCO

dg datadg       default      default  0        1158701822.18.snappy

dm hdb          hdb          auto     2074     8384848  -
dm hdc          hdc          auto     2074     8384848  -
dm hdd          hdd          auto     2074     8384848  -

v  datavol01    -            ENABLED  ACTIVE   2097152  SELECT    -        fsgen
pl datavol01-01 datavol01    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdb-01       datavol01-01 hdb      0        2097152  0         hdb      ENA
pl datavol01-02 datavol01    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdc-01       datavol01-02 hdc      0        2097152  0         hdc      ENA
pl datavol01-03 datavol01    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdd-01       datavol01-03 hdd      0        2097152  0         hdd      ENA

v  datavol02    -            ENABLED  ACTIVE   2097152  RAID      -        raid5
pl datavol02-01 datavol02    ENABLED  ACTIVE   2097152  RAID      3/32     RW
sd hdb-02       datavol02-01 hdb      2097152  1048576  0/0       hdb      ENA
sd hdc-02       datavol02-01 hdc      2097152  1048576  1/0       hdc      ENA
sd hdd-02       datavol02-01 hdd      2097152  1048576  2/0       hdd      ENA

v  datavol03    -            ENABLED  ACTIVE   2097152  SELECT    -        fsgen
pl datavol03-01 datavol03    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdb-03       datavol03-01 hdb      3145728  2097152  0         hdb      ENA

The vxvmconfigbackup shell script can be used to backup the configuration data for all disk groups, a single disk group, or a volume inside a disk group. To backup the configuration needed to recreate the volume datavol01, the volume and disk group names can be passed to the “-v” and “-g” options:

$ vxvmconfigbackup -g datadg -v datavol01 -d /tmp
Backing up volume datavol01 to /tmp/datadg.datavol01.09-19-2006-2658

Now that the configuration of datavol01 is backed up, let’s create a hypothetical problem. Let’s assume that it is 4am, you have been up debugging a problem for 48-hours straight, and you accidentally remove the volume datavol01 instead of datavol03 (I helped an admin recover from a similar situation a few years back, so I know it happens):

$ vxedit -rf rm datavol01

$ vxprint -hft

Disk group: datadg

DG NAME         NCONFIG      NLOG     MINORS   GROUP-ID
ST NAME         STATE        DM_CNT   SPARE_CNT         APPVOL_CNT
DM NAME         DEVICE       TYPE     PRIVLEN  PUBLEN   STATE
RV NAME         RLINK_CNT    KSTATE   STATE    PRIMARY  DATAVOLS  SRL
RL NAME         RVG          KSTATE   STATE    REM_HOST REM_DG    REM_RLNK
CO NAME         CACHEVOL     KSTATE   STATE
VT NAME         NVOLUME      KSTATE   STATE
V  NAME         RVG/VSET/CO  KSTATE   STATE    LENGTH   READPOL   PREFPLEX UTYPE
PL NAME         VOLUME       KSTATE   STATE    LENGTH   LAYOUT    NCOL/WID MODE
SD NAME         PLEX         DISK     DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
SV NAME         PLEX         VOLNAME  NVOLLAYR LENGTH   [COL/]OFF AM/NM    MODE
SC NAME         PLEX         CACHE    DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
DC NAME         PARENTVOL    LOGVOL
SP NAME         SNAPVOL      DCO

dg datadg       default      default  0        1158701822.18.snappy

dm hdb          hdb          auto     2074     8384848  -
dm hdc          hdc          auto     2074     8384848  -
dm hdd          hdd          auto     2074     8384848  -

v  datavol02    -            ENABLED  ACTIVE   2097152  RAID      -        raid5
pl datavol02-01 datavol02    ENABLED  ACTIVE   2097152  RAID      3/32     RW
sd hdb-02       datavol02-01 hdb      2097152  1048576  0/0       hdb      ENA
sd hdc-02       datavol02-01 hdc      2097152  1048576  1/0       hdc      ENA
sd hdd-02       datavol02-01 hdd      2097152  1048576  2/0       hdd      ENA

v  datavol03    -            ENABLED  ACTIVE   2097152  SELECT    -        fsgen
pl datavol03-01 datavol03    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdb-03       datavol03-01 hdb      3145728  2097152  0         hdb      ENA

If you weren’t prepared for this problem, you might respond by screaming a bunch of profanities, and yacking in the nearest garbage can. If you are backing up your configuration, you will most likely take a minute to laugh at yourself, and then you will run vxmake with the “-d” option and the configuration to restore:

$ vxmake -d /tmp/datadg.datavol01.09-19-2006-2658

Once the configuration is restored, the volume will be available for general purpose use:

$ vxprint -hft

Disk group: datadg

DG NAME         NCONFIG      NLOG     MINORS   GROUP-ID
ST NAME         STATE        DM_CNT   SPARE_CNT         APPVOL_CNT
DM NAME         DEVICE       TYPE     PRIVLEN  PUBLEN   STATE
RV NAME         RLINK_CNT    KSTATE   STATE    PRIMARY  DATAVOLS  SRL
RL NAME         RVG          KSTATE   STATE    REM_HOST REM_DG    REM_RLNK
CO NAME         CACHEVOL     KSTATE   STATE
VT NAME         NVOLUME      KSTATE   STATE
V  NAME         RVG/VSET/CO  KSTATE   STATE    LENGTH   READPOL   PREFPLEX UTYPE
PL NAME         VOLUME       KSTATE   STATE    LENGTH   LAYOUT    NCOL/WID MODE
SD NAME         PLEX         DISK     DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
SV NAME         PLEX         VOLNAME  NVOLLAYR LENGTH   [COL/]OFF AM/NM    MODE
SC NAME         PLEX         CACHE    DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
DC NAME         PARENTVOL    LOGVOL
SP NAME         SNAPVOL      DCO

dg datadg       default      default  0        1158701822.18.snappy

dm hdb          hdb          auto     2074     8384848  -
dm hdc          hdc          auto     2074     8384848  -
dm hdd          hdd          auto     2074     8384848  -

v  datavol01    -            ENABLED  ACTIVE   2097152  SELECT    -        fsgen
pl datavol01-01 datavol01    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdb-01       datavol01-01 hdb      0        2097152  0         hdb      ENA
pl datavol01-02 datavol01    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdc-01       datavol01-02 hdc      0        2097152  0         hdc      ENA
pl datavol01-03 datavol01    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdd-01       datavol01-03 hdd      0        2097152  0         hdd      ENA

v  datavol02    -            ENABLED  ACTIVE   2097152  RAID      -        raid5
pl datavol02-01 datavol02    ENABLED  ACTIVE   2097152  RAID      3/32     RW
sd hdb-02       datavol02-01 hdb      2097152  1048576  0/0       hdb      ENA
sd hdc-02       datavol02-01 hdc      2097152  1048576  1/0       hdc      ENA
sd hdd-02       datavol02-01 hdd      2097152  1048576  2/0       hdd      ENA

v  datavol03    -            ENABLED  ACTIVE   2097152  SELECT    -        fsgen
pl datavol03-01 datavol03    ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd hdb-03       datavol03-01 hdb      3145728  2097152  0         hdb      ENA

$ mount -t vxfs /dev/vx/dsk/datadg/datavol01 /a

$ cd /a

$ ls -l

total 1536
-rw-r--r--  1 root root 524288 Sep 19 18:32 data01.dbf
-rw-r--r--  1 root root 524288 Sep 19 18:32 data02.dbf
-rw-r--r--  1 root root 524288 Sep 19 18:32 data03.dbf
drwxr-xr-x  2 root root     96 Sep 19 18:32 lost+found

In addition to be being able to restore the configuration with vxmake’s “-d” option, you can also piece each object back together manually. This is a tedious and error prone process (especially at 4am), so I tend to create configuration backups on all my servers just to be safe. As with all recovery scenarios, you should validate recovery procedures in a test environment prior to using them on a production system.

1 thought on “Recreating Veritas configurations with vxmake”

Leave a Reply

Your email address will not be published. Required fields are marked *