start backup jobs from commandline?

RolandK

Renowned Member
Mar 5, 2019
963
191
88
51
hello,

i have a cluster with 2 backup jobs defined. one for vzdump and one for pbs.

how can i list & start these from commandline ?

thank you
 
To list the backup snapshots from PBS you can use like the below CLI:

Bash:
proxmox-backup-client snapshot list --repository <PBS-IP-Address>:<Datastore-Name>

And to do a backup you can use the `vzdump` tool, e.g.:

Bash:
vzdump <VMID> --node <Node-Name> --storage <PBS-Datastore-Name>

For more information, see the Proxmox BS documentation [0]


[0] https://pbs.proxmox.com/docs/
 
i know.

but my question is on how to manage objects via the commandline, which are creeated/managed in the gui.

in older version the backup job had been a line in cron.d/vzdump

now it seems to exist in

/etc/pve/jobs.cfg

but there is no cli/api interface for this yet , correct !?
 
ah, incorrect.

i have come closer

but how can i run/start such job ?


Code:
# pvesh ls /cluster/backup/
-rw-d        backup-0061ecb9-4fb9
-rw-d        backup-9730afa9-2ed0

# pvesh get  /cluster/backup/backup-9730afa9-2ed0
┌──────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ key              │ value
╞══════════════════╪════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
│ compress         │ zstd
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ enabled          │ 1
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ id               │ backup-9730afa9-2ed0
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ mailnotification │ always
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ mode             │ snapshot
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ notes-template   │ {{guestname}}
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ schedule         │ sun 01:00
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ storage          │ pve-cluster1-backup-cifs
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ type             │ vzdump
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ vmid             │ 230,122,133,103,109,112,125,145,108,155,128,224,163,113,220,186,150,154,158,159,177,240,241,100,134,153,231,137,144,200,106,205,206,207,214,227
└──────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 
ah, incorrect.

i have come closer

but how can i run/start such job ?


Code:
# pvesh ls /cluster/backup/
-rw-d        backup-0061ecb9-4fb9
-rw-d        backup-9730afa9-2ed0

# pvesh get  /cluster/backup/backup-9730afa9-2ed0
┌──────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ key              │ value
╞══════════════════╪════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
│ compress         │ zstd
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ enabled          │ 1
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ id               │ backup-9730afa9-2ed0
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ mailnotification │ always
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ mode             │ snapshot
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ notes-template   │ {{guestname}}
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ schedule         │ sun 01:00
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ storage          │ pve-cluster1-backup-cifs
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ type             │ vzdump
├──────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ vmid             │ 230,122,133,103,109,112,125,145,108,155,128,224,163,113,220,186,150,154,158,159,177,240,241,100,134,153,231,137,144,200,106,205,206,207,214,227
└──────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

So you can't manually run the jobs from the CLI?
 
Hi,
So you can't manually run the jobs from the CLI?
not currently. Only by using the API endpoint and specifying the same parameters as the job. Feel free to create a feature request to start a job via ID from the CLI (hope I didn't miss an existing one): https://bugzilla.proxmox.com/
 
I also need this feature for my planned orchestration script.

Only by using the API endpoint and specifying the same parameters as the job.
Can you give an example please, so we can use this, until there is such an cli command added?
 
I also need this feature for my planned orchestration script.


Can you give an example please, so we can use this, until there is such an cli command added?
You can use vzdump <list of VM IDs> <other options> (or the /nodes/{node}/vzdump API endpoint), where <other options> are those you see in /etc/pve/jobs.cfg or pvesh get /cluster/backup/backup-264b0d6b-2d92 --output-format json-pretty without things like enabled, id, schedule, comment, that are job-specific and vzdump doesn't know about.
 
  • Like
Reactions: Dunuin

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!