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

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Mar 31 11:55:00 CEST 2020


On March 31, 2020 10:38 am, Frans Fürst wrote:
> 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.

both are fine I'd say ;)

> 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).

unfortunately, no such API endpoint exists.

> 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)

the task's 'id' property is only set for backups that backed up a single 
guest (then it gets set to the guest ID). the cluster/backup/id is 
determined by the jobs definition and position inside the crontab file, 
so it's not permanent.

> * I'm not sure whether the task I'm looking for is still there or if it has been cleaned up already

this one you could alleviate by adding a vzdump hook script that parses 
the log after a backup job has been executed, and stores your analysis 
somewhere you control (or even not parses the log, but just uses the 
info the hook script gets directly from vzdump).

> * I have to parse the log manually which is error prone and might change in the future

that one will only change once I or someone else gets around to 
implementing "structured task return values" - right now, a task only 
returns a status and some metadata, but no return value besides the 
textual log.

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

TL;DR: not really (yet), but some alternatives might exist that are good 
enough for now?




More information about the pve-devel mailing list