xref: /dflybsd-src/contrib/lvm2/dist/test/t-vgcfgbackup-usage.sh (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino#!/bin/sh
286d7f5d3SJohn Marino# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
386d7f5d3SJohn Marino#
486d7f5d3SJohn Marino# This copyrighted material is made available to anyone wishing to use,
586d7f5d3SJohn Marino# modify, copy, or redistribute it subject to the terms and conditions
686d7f5d3SJohn Marino# of the GNU General Public License v.2.
786d7f5d3SJohn Marino#
886d7f5d3SJohn Marino# You should have received a copy of the GNU General Public License
986d7f5d3SJohn Marino# along with this program; if not, write to the Free Software Foundation,
1086d7f5d3SJohn Marino# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1186d7f5d3SJohn Marino
1286d7f5d3SJohn Marino. ./test-utils.sh
1386d7f5d3SJohn Marino
1486d7f5d3SJohn Marinoaux prepare_pvs 4
1586d7f5d3SJohn Marino
1686d7f5d3SJohn Marino# vgcfgbackup handles similar VG names (bz458941)
1786d7f5d3SJohn Marinovg1=${PREFIX}vg00
1886d7f5d3SJohn Marinovg2=${PREFIX}vg01
1986d7f5d3SJohn Marinovgcreate $vg1 $dev1
2086d7f5d3SJohn Marinovgcreate $vg2 $dev2
2186d7f5d3SJohn Marinovgcfgbackup -f /tmp/bak-%s >out
2286d7f5d3SJohn Marinogrep "Volume group \"$vg1\" successfully backed up." out
2386d7f5d3SJohn Marinogrep "Volume group \"$vg2\" successfully backed up." out
2486d7f5d3SJohn Marinovgremove -ff $vg1
2586d7f5d3SJohn Marinovgremove -ff $vg2
2686d7f5d3SJohn Marino
2786d7f5d3SJohn Marino# vgcfgbackup correctly stores metadata with missing PVs
2886d7f5d3SJohn Marino# and vgcfgrestore able to restore them when device reappears
2986d7f5d3SJohn Marinopv1_uuid=$(pvs --noheadings -o pv_uuid $dev1)
3086d7f5d3SJohn Marinopv2_uuid=$(pvs --noheadings -o pv_uuid $dev2)
3186d7f5d3SJohn Marinovgcreate $vg $devs
3286d7f5d3SJohn Marinolvcreate -l1 -n $lv1 $vg $dev1
3386d7f5d3SJohn Marinolvcreate -l1 -n $lv2 $vg $dev2
3486d7f5d3SJohn Marinolvcreate -l1 -n $lv3 $vg $dev3
3586d7f5d3SJohn Marinovgchange -a n $vg
3686d7f5d3SJohn Marinopvcreate -ff -y $dev1
3786d7f5d3SJohn Marinopvcreate -ff -y $dev2
3886d7f5d3SJohn Marinovgcfgbackup -f "$(pwd)/backup.$$" $vg
3986d7f5d3SJohn Marinosed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1"
4086d7f5d3SJohn Marinopvcreate -ff -y -u $pv1_uuid $dev1
4186d7f5d3SJohn Marinopvcreate -ff -y -u $pv2_uuid $dev2
4286d7f5d3SJohn Marinovgcfgrestore -f "$(pwd)/backup.$$1" $vg
43