-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore_vms
More file actions
executable file
·41 lines (28 loc) · 828 Bytes
/
restore_vms
File metadata and controls
executable file
·41 lines (28 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#restore of lvm backed vms
backup_mountpoint="/mnt/ssnas1"
#lvs of vms to restore
lvs=$(ls ${lvpath})
lvpath="/dev/vmvg1"
GZIP="unpigz"
if [ `which pv >/dev/null;echo $?` -eq 0 ];then
PV="pv"
else
PV="cat"
fi
#check that backup mountpoint is mounted
mountpoint -q ${backup_mountpoint}||mount ${backup_mountpoint} >/dev/null 2>&1
mountpoint -q ${backup_mountpoint} >/dev/null 2>&1
if [ $? -ne 0 ];then
echo "ssnas1 not mounted, exiting."
exit 1
fi
for lv in $lvs;do
echo -en "\nrestoring ${backup_mountpoint}/$(hostname)/${lv}.gz to $lvpath/$lv\n"
nice ionice -n2 $PV ${backup_mountpoint}/$(hostname)/${lv}.gz|nice $GZIP -c -|dd of=$lvpath/$lv bs=2M iflag=fullblock
if [ $? -ne 0 ];then
echo "restore of $lv failed, exiting."
exit 3
fi
echo -e "restore of $lv complete\n"
done