I am using Xen, and for each of our VM's we have set up a process to create a new snapshot of the VM every morning, with the last seven being kept.
I am now trying to write a script to test restoring the latest snapshot for each VM.
In Xen command line I can get a list of all the snapshots for a given VM using:
xe snapshot-list snapshot-of=${vm_uuid}
which returns seven entires in the following format:
uuid ( RO) : fc6cb150-b264-830e-4fb9-7fec030e434d
name-label ( RW): 20220616-0118
name-description ( RW):
is-vmss-snapshot ( RO): true
Is there an easy way to find out which is the latest one, as so far all I have to go is the date in the name-label (e.g. 20220616
), but the second part of the name (0118
) changes with each snapshot, and as far as I can tell I can't use wildcards with the name-label
option of xe
e.g.
xe snapshot-list snapshot-of=${vm_uuid} name-label=20220616*