Finding all snapshots in cluster

Sudodude

New Member
May 24, 2022
12
1
3
Hello,

I am running a 5-node HA ceph cluster. I like to occasionally look for old snapshots that are no longer needed so I can remove them. I have been trying to figure out a good way to scan the entire cluster for snapshots but have not had good results so far. Currently I run this command on each node:

Code:
for x in $(qm list | tail +2 | awk '{print $1}'); do echo -n $x; qm status $x -verbose| grep name | cut -d':' -f2; qm listsnapshot $x | grep -v current; done

It's not pretty, but it works in showing the VM ID, name, and all snapshots that each VM may have.

Does anyone have a suggestion on how I can get all the snapshots from the cluster without having to run this on each node?

Thank you!
 
You should be using API. A good start would be to process output of "pvesh".
i.e.: pvesh get /cluster/resources
Use jq to process json: pvesh get /cluster/resources --output-forma json
You can do all the same stuff you do now, except query entire cluster and any VM or storage.
If you want to run this off the PVE, you can use "curl" to send the APIs.



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I have used pvesh to look at which values are returned, but unless I overlooked it I did not see any snapshot details.
 
Thanks for the command. Unfortunately when I run it in bash, it errors with
Code:
400 too many arguments
 
Thanks for the command. Unfortunately when I run it in bash, it errors with
What exactly did you run? The code I provided was "pseudo code" few steps away from being runnable directly. Its missing all the "jq" processing. It was meant to point you in the right direction not as a finaloutput.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!