add snapshots and zfs send/recv
This commit is contained in:
parent
0b07035565
commit
b8aed5fe45
@ -39,5 +39,34 @@ for disk in $VMDISKS
|
|||||||
do
|
do
|
||||||
DISKSPEC+="--discspec $disk,file=/srv/snapshots/$VM/$VM-$disk-$SNAPNAME.qcow2,snapshot=external "
|
DISKSPEC+="--discspec $disk,file=/srv/snapshots/$VM/$VM-$disk-$SNAPNAME.qcow2,snapshot=external "
|
||||||
done
|
done
|
||||||
echo $DISKSPEC
|
|
||||||
|
virsh snapshot-create-as --domain $VM --name $SNAPNAME --quiesce --atomic --disk-only $DISKSPEC > /dev/null
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "VM snapshot creation failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
zfs snapshot "$SRCZFS"@"$SNAPNAME"
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "ZFS snapshot creation failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for disk in $VMDISKS
|
||||||
|
do
|
||||||
|
virsh blockcommit $VM $disk --pivot --active >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
VMDISKS=$(virsh domblklist $VM | egrep vd.)
|
||||||
|
for disk in $VMDISKS
|
||||||
|
do
|
||||||
|
if [[ $disk == *"snapshot"* ]]
|
||||||
|
then
|
||||||
|
echo "Snapshot deletion failed for $disk" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
zfs send "$SRCZFS"@"$SNAPNAME" | pv -L 500M | ssh $DESTHOST sudo zfs recv -F $DESTZFS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user