virsh snapshot-create-as win7 snap01 --description "something here"
How could I list snapshots list with the description ?
I managed to do a simple bash script to list all VMs and the snapshots description:
#!/bin/bash
vmdomains=`sudo virsh list --all | sed 1,2d | awk '{ print $2 }'`
echo -ne "Domain\t\t\tSnapshot Name\t\t\tDescription\n"
echo "-----------------------------------------------------------------------------------------"
for vmdomain in $vmdomains; do
echo -ne "$vmdomain\t\t"
snapshots=`sudo virsh snapshot-list $vmdomain | sed 1,2d | awk '{ print $1 }'`
snapshotflag=0
for snapshot in $snapshots; do
snapshotflag=1
echo -ne "$snapshot\t\t"
sudo virsh snapshot-dumpxml --domain $vmdomain --snapshotname $snapshot | grep "<description>" | sed 's/ <description>//' | sed 's/<\/description>//'
done
if [ $snapshotflag -eq 0 ]; then
echo
fi
done
Edit: Output example
~$ sh listsnap.sh
Domain Snapshot Name Description
-------------------------------------------------------------------------------------
Win10 Win10_Disabled_Updates Used gpedit to disable updates
Win10 Win10_games_installed Gaming Rig with passtrhough gpu
CentOS CentOS_origin Installed Nginx and web dependencies
CentOS CentOS_Wednesday Installed Anaconda and Julia
CentOS CentOS_weekend Updated PIP dependencies
Fedora
Ubuntu Testing_nfs_Ubuntu Configured nfs server
Edit: This was a quick script and may not handle all cases in the best way, see other scripts posted here for more detailed workaround. Also RHEL web console already shows snapshot descriptions Yay!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With