[SOLVED] Proxmox API prune-backups invalid format

willifehler

New Member
Jul 17, 2023
7
0
1
Hello,

I'm trying to setup a Backup Job in Proxmox VE using the API.

Bash:
root@...:~# pveversion
pve-manager/7.4-3/9002ab8a (running kernel: 5.15.107-1-pve)

My .json file:

JSON:
{
   "compress":"zstd",
   "enabled":1,
   "mailnotification":"always",
   "mailto":"...",
   "mode":"snapshot",
   "notes-template":"{{guestname}}",
   "prune-backups": {
     "keep-last": "5"
   },
   "schedule":"mon..fri 00:00",
   "storage":"cephfs",
   "vmid":"112"
}

I'm getting this response:

Bash:
HTTP/1.1 400 Parameter verification failed.
Cache-Control: max-age=0
Connection: close
Content-Length: 121
Content-Type: application/json;charset=UTF-8
Date: Mon, 17 Jul 2023 09:09:21 GMT
Expires: Mon, 17 Jul 2023 09:09:21 GMT
Pragma: no-cache
Server: pve-api-daemon/3.0

{
    "data": null,
    "errors": {
        "prune-backups": "invalid format - value without key, but schema does not define a default key\n"
    }
}

If I remove prune-backups the job will be created fine.

How can I pass prune-backups as a key by using the API?

Regards - Willi
 
Last edited:
If I create a backup in the WebUI:

Bash:
root@...:~# pvesh get /cluster/backup/backup-335029a3-0168
┌──────────────────┬──────────────────────┐
│ key              │ value                │
╞══════════════════╪══════════════════════╡
│ compress         │ zstd                 │
├──────────────────┼──────────────────────┤
│ enabled          │ 1                    │
├──────────────────┼──────────────────────┤
│ id               │ backup-335029a3-0168 │
├──────────────────┼──────────────────────┤
│ mailnotification │ always               │
├──────────────────┼──────────────────────┤
│ mailto           │ ...                  │
├──────────────────┼──────────────────────┤
│ mode             │ snapshot             │
├──────────────────┼──────────────────────┤
│ notes-template   │ {{guestname}}        │
├──────────────────┼──────────────────────┤
│ prune-backups    │ {"keep-last":"5"}    │
├──────────────────┼──────────────────────┤
│ schedule         │ mon..fri 00:00       │
├──────────────────┼──────────────────────┤
│ storage          │ cephfs               │
├──────────────────┼──────────────────────┤
│ type             │ vzdump               │
├──────────────────┼──────────────────────┤
│ vmid             │ 101,110,111,112      │
└──────────────────┴──────────────────────┘

So the value keep-last should be fine?!
 
Hi,

if you look at the API documenation for /cluster/backup (which I assume you are using),
the prune-backups parameter does not take an (JSON) object, but rather a comma-separated string.

So in your case, the request body should look like this:
JSON:
{
  ..,
  "prune-backups": "keep-last=5",
  ..
}
 
Great to hear that solved your problem!

Please just mark the thread as solved by editing the first post - there should be a dropdown near the title field. This helps other people with the same problem to more easily find this thread in the future! :)
 

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!