Getting a global list of snapshots

damo2929

Member
Mar 15, 2022
119
19
23
45
Oxfordshire, United Kingdom
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: