PVE::VZDump::verify_vzdump_parameters($param, 1);
# silent exit if we run on wrong node
- exit(0) if $param->{node} && $param->{node} ne $nodename;
+ return 'OK' if $param->{node} && $param->{node} ne $nodename;
- if($param->{stop}){
- PVE::VZDump::stop_all_backups;
- }
-
my $cmdline = PVE::VZDump::command_line($param);
# convert string lists to arrays
my @vmids = PVE::Tools::split_list(extract_param($param, 'vmid'));
+ if($param->{stop}){
+ PVE::VZDump::stop_running_backups();
+ return 'OK' if !scalar(@vmids);
+ }
+
my $skiplist = [];
if (!$param->{all}) {
if (!$param->{node}) {
}
@vmids = @localvmids;
# silent exit if specified VMs run on other nodes
- exit(0) if !scalar(@vmids);
+ return "OK" if !scalar(@vmids);
}
$param->{vmids} = PVE::VZDump::check_vmids(@vmids)
die "you can only backup a single VM with option --stdout\n"
if $param->{stdout} && scalar(@vmids) != 1;
- foreach my $key (qw(maxfiles tmpdir dumpdir script size bwlimit ionice)) {
+ foreach my $key (qw(maxfiles tmpdir dumpdir script bwlimit ionice)) {
raise_param_exc({ $key => "Only root may set this option."})
if defined($param->{$key}) && ($user ne 'root@pam');
}
$rpcenv->check($user, "/storage/$param->{storage}", [ 'Datastore.AllocateSpace' ])
if $param->{storage};
- my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist);
-
my $worker = sub {
+ my $upid = shift;
+
$SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
die "interrupted by signal\n";
};
+ my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist);
+
eval {
- $vzdump->getlock(); # only one process allowed
+ $vzdump->getlock($upid); # only one process allowed
};
- if ($@) {
- $vzdump->sendmail([], 0, $@);
+ if (my $err = $@) {
+ $vzdump->sendmail([], 0, $err);
exit(-1);
}
return $rpcenv->fork_worker('vzdump', undef, $user, $worker);
}});
+
+__PACKAGE__->register_method ({
+ name => 'extractconfig',
+ path => 'extractconfig',
+ method => 'GET',
+ description => "Extract configuration from vzdump backup archive.",
+ permissions => {
+ description => "The user needs 'VM.Backup' permissions on the backed up guest ID, and 'Datastore.AllocateSpace' on the backup storage.",
+ user => 'all',
+ },
+ protected => 1,
+ proxyto => 'node',
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ volume => {
+ description => "Volume identifier",
+ type => 'string',
+ completion => \&PVE::Storage::complete_volume,
+ },
+ },
+ },
+ returns => { type => 'string' },
+ code => sub {
+ my ($param) = @_;
+
+ my $volume = extract_param($param, 'volume');
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+
+ my $storage_cfg = PVE::Storage::config();
+ $rpcenv->check_volume_access($authuser, $storage_cfg, undef, $volume);
+
+ return PVE::Storage::extract_vzdump_config($storage_cfg, $volume);
+ }});
+
+1;