-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to create libvirt external snapshots in a loop
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
# Purpose: For a given libvirt guest, create 100 external live-snapshots | ||
# i.e. each snapshot is stored in a unique QCOW2 file | ||
|
||
#set -x | ||
|
||
PROGNAME=`basename $0` | ||
|
||
DOMAIN=$1 | ||
|
||
SNAPSHOTS_DIR=/export/vmimages | ||
|
||
# Create external snapshots | ||
create_external_snapshot() { | ||
let i=0 | ||
while [ $i -lt 100 ];do | ||
echo "Creating $DOMAIN-snap$i" | ||
virsh snapshot-create-as --domain $DOMAIN \ | ||
--name snap-$i \ | ||
--description snap$i-desc \ | ||
--disk-only \ | ||
--diskspec hda,snapshot=external,file=$SNAPSHOTS_DIR/$DOMAIN-snap$i.qcow2 \ | ||
--atomic | ||
let i=i+1 | ||
done | ||
} | ||
|
||
# main () | ||
{ | ||
|
||
# Check if min no. of arguments are 1 | ||
if [ "$#" != 1 ]; then | ||
echo "Provide the libvirt guest name." | ||
echo "e.g. $PROGNAME f20vm1" | ||
exit 255 | ||
fi | ||
|
||
|
||
create_external_snapshot | ||
|
||
} |