How to get vmid in vzdump hook script?

Dec 25, 2017
23
0
21
35
I do not understand PERL, but example vzdump-hook-script.pl in this language.

in the example
my $phase = shift;
my $vmid = shift;

How to get vmid in bash?
 
You can get the list of your containers with "pct list", the first column is the ID. In the web interface it's also the number that is displayed next to the name in the overview.

Hope that helps :)
 
You can get the list of your containers with "pct list", the first column is the ID. In the web interface it's also the number that is displayed next to the name in the overview.

Hope that helps :)

I know that :)

got so:

#!/bin/bash
vmid=$3
if [ "$1" == "backup-start" ]; then
echo $vmid >> /root/vzdump-test.log
fi
 
I know that :)

got so:

#!/bin/bash
vmid=$3
if [ "$1" == "backup-start" ]; then
echo $vmid >> /root/vzdump-test.log
fi

Ah, my bad, misunderstood you there. Yes, it's the third argument of the hook call, so $3 is the correct approach.

First argument is the phase (job-start, job-end or job-abort), second the mode (stop, suspend or snapshot), and third one the vmid. Please also notice the usage of environment variables in the example script.
 
Last edited:

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!