How to get vmid in vzdump hook script?

Dec 25, 2017
23
0
21
36
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: