Skip to content

Instantly share code, notes, and snippets.

@gilou
Created July 17, 2017 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilou/ddcc7de96dbbf7d9921243da125e816f to your computer and use it in GitHub Desktop.
Save gilou/ddcc7de96dbbf7d9921243da125e816f to your computer and use it in GitHub Desktop.
Originally oneliner to clean up snapshots in reverse order on a VirtualBox machine.
VM_NAME="MyVM"
# Use tac to reverse list given by --machinereadble outut of VBoxManage.
# Get ID from the SnapshotUUID-1-1-1-1-1-1="76c627e3-1c0a-4d0c-b680-b4f1c6175dac" output
for snap in $(VBoxManage snapshot "$VM_NAME" list --machinereadable| grep '^SnapshotUUID' | tac - | sed 's/SnapshotUUID\(-[0-9-]\+\)\?="\([0-9a-f-]\+\)"/\2/g') ; do
echo "Deleting Snap $snap" ; VBoxManage snapshot "$VM_NAME" delete "$snap"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment