Q: PBS - CLI based 'list snapshots' mini report?

fortechitsolutions

Renowned Member
Jun 4, 2008
477
62
93
Hi, I am trying to figure out if there is a way that I may easily generate a report of "current snapshots overview" via CLI on a PBS server
so that I might for example make a little cron job > call a wrapper script > send a nightly report to 'people who are interested' that provides status of the PBS Backups on a PBS server

in the WebUI we have a helpful high-level rendering where we look at top-level of "Content" which hints to us things like
root namespace > list of CT and VM which exist on this PBS datastore
and then for each, it tells me the most recent snap that exists (ie, today-date vs 3 months ago date for example) and then a count of how many snaps exist for each

an illustrative example graphic snip to show what I mean:
PBS snip example.png

So, what I'm wondering is if there is a CLI_Based method to generate a similar report which I can spit out to an email
so that people who are interested might just expect to see a nightly report email in their inbox from PBS_Server
and not require them to go login to the PBS box to check status and make sure "hey, last good backup is 6 months ago, maybe I have a problem" vs "ok yes good we have backup from last night, and many copies exist, so happy day is here again for my backup status"

I've poked gently at the CLI "proxmox-backup-manager' and a few google searches have given me some bogus AI suggestions on how to get this CLI tool to spit back to me a list of things that seem like what I want - except that from what I can tell these commands are bogus / or depreciated / or ai dreaming?

if someone can give me a gentle kick into the proper direction to find a way towards this it would be greatly appreciated

I did try to dig through the pbs documentation online, and am having trouble getting anywhere

thank you,

Tim
 
Hi!

I think what you're looking for might be proxmox-backup-client snapshot list [<group>], no? You could create a little wrapper script around that which gives you the output per group (ct/104, ct/105, vm/100, etc.).
 
Last edited:
In addition to the response of @mkoeppl, you can also consume the api contents directly, e.g. proxmox-backup-debug api get /admin/datastore/{datastore}/snapshots --output-format=json gives you the same information you see via the Contents tab as json for further processing. The same might of course be obtained via another (authenticated) api client.
 
  • Like
Reactions: mkoeppl
Thank you for the quick replies!

Michael - I quickly tried this and not sure I will go this route - the backup-client is not installed on my PBS server already. In this particular situation I am attempting to render the backups report locally in the PBS server itself, which is in this case also an offsite PBS that holds sync job PBS backups from an onsite PBS server. This PBS host itself has no direct-linked proxmox / no direct linked client. Possibly? I can install the pbs-client software here and then use these commands to manage-manipulate the local PBS store but I am feeling like that is maybe not my preferred route.

Chris - I followed your hint and I am nearly there, so far I can get a nice concise high level report, my only thing to figure out is how to massage the "last-backup" field so that it is more human-friendly in terms of "what day-time does this mean?"

as per:

Code:
root@debian:~# proxmox-backup-debug api get /admin/datastore/pbsoffsite/groups
┌──────────────┬─────────────────────────────────────────────────────────────────────────────────────────────┬─────────────┬───────────┬─────────────┬─────────┬──────────┐
│ backup-count │ files                                                                                       │ last-backup │ backup-id │ backup-type │ comment │ owner    │
╞══════════════╪═════════════════════════════════════════════════════════════════════════════════════════════╪═════════════╪═══════════╪═════════════╪═════════╪══════════╡
│           29 │ ["qemu-server.conf.blob","drive-scsi0.img.fidx","index.json.blob","client.log.blob"]        │  1763608001 │ 107       │ vm          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           31 │ ["root.pxar.didx","index.json.blob","catalog.pcat1.didx","client.log.blob","pct.conf.blob"] │  1763607966 │ 106       │ ct          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["root.pxar.didx","index.json.blob","catalog.pcat1.didx","client.log.blob","pct.conf.blob"] │  1763607941 │ 104       │ ct          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["qemu-server.conf.blob","drive-scsi0.img.fidx","index.json.blob","client.log.blob"]        │  1763607650 │ 101       │ vm          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["drive-virtio0.img.fidx","qemu-server.conf.blob","index.json.blob","client.log.blob"]      │  1763607771 │ 103       │ vm          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["drive-virtio0.img.fidx","qemu-server.conf.blob","index.json.blob","client.log.blob"]      │  1763607605 │ 100       │ vm          │         │ root@pam │
└──────────────┴─────────────────────────────────────────────────────────────────────────────────────────────┴─────────────┴───────────┴─────────────┴─────────┴──────────┘
root@debian:~#

Tim
 
Chris - I followed your hint and I am nearly there, so far I can get a nice concise high level report, my only thing to figure out is how to massage the "last-backup" field so that it is more human-friendly in terms of "what day-time does this mean?"
this is the unix epoch timestamp of the last backup snapshot of the group
 
Thank you Chris - I kind of guessed that might be the case but - I appreciate the clarity.

I did a bit of gentle google digging and found that this does a tolerable job of converting output for my purposes
in case this is of interest to anyone else.

-Tim

Code:
root@debian:/etc/postfix# cat /opt/bin/nightly-backup-report-script


#!/bin/bash
# trivial script to generate report for backup status, will be called by cron and sent via email to people for review easily
########
proxmox-backup-debug api get /admin/datastore/pbsoffsite/groups  > /tmp/output
while IFS= read -r line; do
    epoch=$(echo "$line" | grep -Eo '[0-9]{10}')
    if [[ -n "$epoch" ]]; then
        human_date=$(date -d "@$epoch" +"%Y-%m-%d %H:%M:%S")
        line=${line//$epoch/$human_date}
    fi
    echo "$line"
done < /tmp/output
rm /tmp/output

The output is not terribly pretty, as the 'formatting' expects a certain wide field for date which is no longer true
but it is more than adequate to tell the required info so I think I will go with it for now.

sample output is thus for reference

Code:
root@debian:/opt/bin# ./nightly-backup-report-script
┌──────────────┬─────────────────────────────────────────────────────────────────────────────────────────────┬─────────────┬───────────┬─────────────┬─────────┬──────────┐
│ backup-count │ files                                                                                       │ last-backup │ backup-id │ backup-type │ comment │ owner    │
╞══════════════╪═════════════════════════════════════════════════════════════════════════════════════════════╪═════════════╪═══════════╪═════════════╪═════════╪══════════╡
│           29 │ ["qemu-server.conf.blob","drive-scsi0.img.fidx","index.json.blob","client.log.blob"]        │  2025-11-19 22:06:41 │ 107       │ vm          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           31 │ ["root.pxar.didx","index.json.blob","catalog.pcat1.didx","client.log.blob","pct.conf.blob"] │  2025-11-19 22:06:06 │ 106       │ ct          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["root.pxar.didx","index.json.blob","catalog.pcat1.didx","client.log.blob","pct.conf.blob"] │  2025-11-19 22:05:41 │ 104       │ ct          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["qemu-server.conf.blob","drive-scsi0.img.fidx","index.json.blob","client.log.blob"]        │  2025-11-19 22:00:50 │ 101       │ vm          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["drive-virtio0.img.fidx","qemu-server.conf.blob","index.json.blob","client.log.blob"]      │  2025-11-19 22:02:51 │ 103       │ vm          │         │ root@pam │
├──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┼─────────────┼───────────┼─────────────┼─────────┼──────────┤
│           37 │ ["drive-virtio0.img.fidx","qemu-server.conf.blob","index.json.blob","client.log.blob"]      │  2025-11-19 22:00:05 │ 100       │ vm          │         │ root@pam │
└──────────────┴─────────────────────────────────────────────────────────────────────────────────────────────┴─────────────┴───────────┴─────────────┴─────────┴──────────┘
root@debian:/opt/bin#

Thank you team@Proxmox for making things that can be accessible in a manner like this! :-)

Tim
 
  • Like
Reactions: waltar