[SOLVED] Verify single snapshot from CLI ?

hvisage

Renowned Member
May 21, 2013
278
26
93
Good day,

In the GUI I can select a specific Snapshot to verify, but I can't find an equivalent in the CLI commands?
Reason: I've copied the datastore files from a to-be-decommisioned PBS to the new server over the network, but there had been some rsync errors, so I want to run over those with errors, to grab the files needed for them and then to selectively re-verify those instead of a full verification of the datastore
 
Hi,

You can by issuing a cURL command, as a POST request with this endpoint /api2/extjs/admin/datastore/{store}/verify [0] and in the data you can gives the following (You have to change the CTID to the ID of the container, if you want to verify the single a VM you may replace the backup-type=ct to backup-type=vm and so on):

Code:
backup-type=ct&backup-id=<CTID>


[0] https://pbs.proxmox.com/docs/api-viewer/index.html#/admin/datastore/{store}/verify
 
Hey,

instead of curl you can also use proxmox-backup-debug api. Here it would look something like proxmox-backup-debug api create /admin/datastore/datastore1/verify --backup-type=vm --backup-id=115 --ignore-verified=false, proxmox-backup-debug api is basically a wrapper for the API, just without the authentication stuff since you are already on the server. You can lookup the available options at [0], as mentioned by @Moayad.

But generally I'd say it would make sense to have those options also available in the "normal" CLI.
 
How I did it:
(1) first set all the PBS_.... environment paramters (YEs, I could've done it all with proxmox-backup-debug, I was just reusing already tehre stuff ...)
Then created this file as verify-delete

Bash:
#!/bin/bash
echo $*
echo

proxmox-backup-debug api create /admin/datastore/MWproxCrit/verify $* --ignore-verified=false && \
proxmox-backup-debug api delete /admin/datastore/MWproxCrit/snapshots $*

and the CLI run to grab the list of snapshots, match the not OK verify states, output a set of commandlint paramaters, make then all null terminated stream by replacing the new lines, and using xargs run 16 at a time with the above to verify and delete if error

Bash:
proxmox-backup-client snapshot list --output-format json \
 | jq -r '.[]|select(.verification.state != "ok")| "--backup-type=" + ."backup-type" + " --backup-id="+ ."backup-id" + " --backup-time=" + (."backup-time"|tostring) ' \
 | tr '\n' '\0' \
 | xargs -0 -n1 -P16 ./verify-delete

CAVEAT EMPTOR: If you hit control-C the verify jobs busy, WILL fail, and you will get a deleted snapshot... ie. it's NOT a perfect script that needs a trap or three
 

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!