Getting a global list of snapshots

damo2929

Member
Mar 15, 2022
106
15
23
44
Hi all
on vmware you can get the system to alert for systems with snapshots over a certain age.

I am looking for write a script of some kind to do the same for proxmox, but does anybody know how to get a global list of snapshots across all the VM's?

I know that it's most likey going to need the API, am assuming that the only way to do this will be to get a list of the VM's and then loop over them to get a list unless
there is a better way.
 
There might be a similar way with Ceph, however a PVE centric, storage independent, way would look something like this
(not production ready code):
Code:
mycluster=$(pvesh get /cluster/resources --output json)
cutoff=$(date --date="-30days" +%s)
for myvm in $(jq -r '.[]|select(.type == "qemu")|.node+"/"+.id' <<< $mycluster);do
  mysnap=$(pvesh  get /nodes/"$myvm"/snapshot --output json);
  mysnaptime=$(jq -r '.[].snaptime' <<< $mysnap);
  if [[ $cutoff -gt $mysnaptime ]];then
    echo Snapshot is more than 30 days old $mysnaptime;
  fi;
done


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

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 yours easily in our online shop.

Buy now!