Created
August 24, 2017 07:49
-
-
Save jfrancoa/ea4852e40515c5dced2a4094a2014a92 to your computer and use it in GitHub Desktop.
Bash functions for snapshots
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
#!/bin/bash | |
# If argument specified then it will be used as snapshot name. | |
# For example: $ restore fresh-install; will restore all snapshots named $domain-fresh-install | |
function restore() { | |
vms=( $(virsh list --all | grep running | awk '{print $2}') ) | |
for i in "${vms[@]}"; | |
do | |
virsh shutdown $i | |
sleep 120 | |
virsh snapshot-revert --domain $i --snapshotname $i-$1 --running | |
done | |
} | |
function snapshot() { | |
vms=( $(virsh list --all | grep running | awk '{print $2}') ) | |
for i in "${vms[@]}"; | |
do | |
virsh snapshot-create-as --domain "$i" --name "$i"-$1 --description "$i"-$1 --atomic | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment