[SOLVED] PBS API - Optional parameter "since" not working correctly.

dmilbert

New Member
Jul 13, 2021
11
3
3
23
Hi,

I am currently in the process of writing a script to send E-Mail notifications about the status of each VM's backup in Proxmox.
To do this I am using the following API URL to get the Tasks/Backup Jobs of the previous night:
Code:
https://prx-backup.local:8007/api2/json/nodes/prx-backup/tasks?since=1626091200

The timestamp is autogenerated using PHP and is then inserted into the URL.
I used the optional "since" parameter a week ago and it work perfectly, however about 3 days ago a backup task for one of the VM's "Got stuck" for 3 days and we ended up having to manually end/cancel it.

This cancelled task when fetched via the API has a Start time of 1625835454 and an end time of 1626161424 (roughly 3 days in between timestamps).

This seems to have caused an issue with the API, when fetching the backup tasks for yesterday ( 24 hours ago ) no backup tasks are given/listed by the API even though other VM's created their backups successfully, however when fetching the backup tasks from 4 days ago the API then gives a list of the backup tasks created yesterday and the cancelled backup task.

Below is the code I used to connect to the API:
Code:
  function get_backup_tasks() {
    // generate a timestamp for the previous day
    $hour = 12;
    $today = strtotime($hour . ':00:00');
    
    // Below timestamp does not give any tasks (used to work)
    $yesterday = strtotime('-1 day', $today);
    // Below timestamp works since the "stuck" backup task was cancelled
    $yesterday = strtotime('-4 day', $today);
    
    // get a list of backups/tasks performed since yesterday
    $ch = curl_init();
    $api_task_url = "https://prx-backup.local:8007/api2/json/nodes/prx-backup/tasks?since=".$yesterday;
    echo $api_task_url."\n";
    $header = array(
      'Accept: application/json',
      'Authorization: PBSAPIToken= =========== Token comes here ========'
    );
    curl_setopt($ch, CURLOPT_URL, $api_task_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $output=curl_exec($ch);
    curl_close($ch);
    $data=json_decode($output, true);
    return $data;
  }

I have attached the output from the function from a print_r() on the $data variable.
 

Attachments

  • Output when requesting backup tasks from API.txt
    2.8 KB · Views: 0
sounds like a bug - could you file an entry at https://bugzilla.proxmox.com and include the data from this post + the installed package versions on the PBS system (proxmox-backup-manager versions --verbose)? my guess is the task info iterator gets confused somehow..
 
Hi, so in bugzilla it says a patch has been sent to the devel list, how long until this patch then becomes available for install (How long must one wait before a patch/fix is implemented?)
 

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!