Using the Proxmox VE API I want to get status information for all all configured backup jobs (those you can find below cluster/backup/{id}/
). There I can see which VMs are being backed up and when the backup should take place but I can't see the status of the last backup (better would be last N).
What I need is information like this:
VMID | Job-ID | Started | Status | Duration | Size
123 | a39..8ab | 2020-01-16 00:00:02 | OK | 1:23 | 7.81GB
131 | f3h..ab4 | 2020-01-16 00:00:02 | OK | 0:37 | 1.23GB
What I can see is a list of tasks which have been run on a given node, say node/{node}/tasks/{upid}/status|log
. There I find an exit status and a console log:
INFO: starting new backup job: vzdump 101 102 103 104 105 100 --compress lzo --quiet 1 --storage QNAP --mailnotification always --mode snapshot --mailto ***@**.com
INFO: Starting Backup of VM 100 (qemu)
INFO: Backup started at 2020-01-16 00:00:02
INFO: status = running
INFO: update VM 100: -lock backup
INFO: VM Name: ****.**.tribe29.com
INFO: include disk 'scsi0' 'local-zfs:vm-100-disk-0' 60G
INFO: backup mode: snapshot
INFO: ionice priority: 7
INFO: creating archive '/mnt/pve/QNAP/dump/vzdump-qemu-100-2020_01_16-00_00_02.vma.lzo'
INFO: started backup task 'd9f7c327-e610-4e38-931e-2251c9548e76'
INFO: status: 0% (319356928/64424509440), sparse 0% (115822592), duration 4, read/write 79/50 MB/s
INFO: status: 1% (678428672/64424509440), sparse 0% (151867392), duration 7, read/write 119/107 MB/s
INFO: status: 2% (1372258304/64424509440), sparse 0% (212226048), duration 17, read/write 69/63 MB/s
...
INFO: status: 98% (63369576448/64424509440), sparse 85% (54797918208), duration 164, read/write 399/86 MB/s
INFO: status: 100% (64424509440/64424509440), sparse 86% (55852843008), duration 165, read/write 1054/0 MB/s
INFO: transferred 64424 MB in 165 seconds (390 MB/s)
INFO: archive file size: 4.53GB
Relevant data I could get from here (by parsing the log):
node/{node}/tasks/{upid}/status
What I'm missing:
node/{node}/tasks/{upid}
to cluster/backup/{id}
(for me node/{node}/tasks/{upid}/status/id
is always empty)So is there a way for me to get information like this via the API directly:?
Currently there's nothing like this - you would have to parse the log-entries you can retrieve via API on nodes/{node}/tasks/{upid}/log
.
If you need to now how: Checkmk reads the logs for internal purposes, you can find the code here: https://github.com/tribe29/checkmk/blob/master/cmk/special_agents/agent_proxmox.py, in the class BackupTask
.
Disclaimer: I'm tribe29 employee and wrote this code after posting this question.