[pve-devel] How to get VM backup status via PVE API?

Frans Fürst frans.fuerst at tribe29.com
Tue Mar 31 10:38:22 CEST 2020


Hi, I'm not sure whether this is a `pve-devel` or rather a `pve-user` question, but since I'm developing against the Proxmox VE API I'm trying it here first.

I want to get a status for all configured backup jobs via the PVE API (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 *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):

* VMID: 100
* started at 2020-01-16 00:00:02"
* '/mnt/pve/QNAP/dump/vzdump-qemu-100-2020_01_16-00_00_02.vma.lzo'
* backup task 'd9f7c327-e610-4e38-931e-2251c9548e76'
* 64424 MB
* 165 seconds (390 MB/s)
* archive file size: 4.53GB
* exit status via `node/{node}/tasks/{upid}/status`

What I'm missing:

* a way to link `node/{node}/tasks/{upid}` to `cluster/backup/{id}` (for me `node/{node}/tasks/{upid}/status/id` is always empty)
* I'm not sure whether the task I'm looking for is still there or if it has been cleaned up already
* I have to parse the log manually which is error prone and might change in the future

So is there a way for me to get information like this via the API directly:?

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

Thanks
Frans



More information about the pve-devel mailing list