]> git.proxmox.com Git - pve-manager.git/blobdiff - PVE/VZDump.pm
fix #949: add post-restart hook to vzdump
[pve-manager.git] / PVE / VZDump.pm
index 61341ca16159bf62ce5b6a2d408ed7e91c653744..3101b6a25e6896fada26d86556b8ce2b743d49ea 100644 (file)
@@ -16,6 +16,8 @@ use PVE::Cluster qw(cfs_read_file);
 use Time::localtime;
 use Time::Local;
 use PVE::JSONSchema qw(get_standard_option);
+use PVE::HA::Env::PVE2;
+use PVE::HA::Config;
 
 my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
 
@@ -27,6 +29,157 @@ my $logdir = '/var/log/vzdump';
 
 my @plugins = qw();
 
+my $confdesc = {
+    vmid => {
+       type => 'string', format => 'pve-vmid-list',
+       description => "The ID of the guest system you want to backup.",
+       completion => \&PVE::Cluster::complete_local_vmid,
+       optional => 1,
+    },
+    node => get_standard_option('pve-node', {
+       description => "Only run if executed on this node.",
+       completion => \&PVE::Cluster::get_nodelist,
+       optional => 1,
+    }),
+    all => {
+       type => 'boolean',
+       description => "Backup all known guest systems on this host.",
+       optional => 1,
+       default => 0,
+    },
+    stdexcludes => {
+       type => 'boolean',
+       description => "Exclude temporary files and logs.",
+       optional => 1,
+       default => 1,
+    },
+    compress => {
+       type => 'string',
+       description => "Compress dump file.",
+       optional => 1,
+       enum => ['0', '1', 'gzip', 'lzo'],
+       default => '0',
+    },
+    pigz=> {
+       type => "integer",
+       description => "Use pigz instead of gzip when N>0.".
+           " N=1 uses half of cores, N>1 uses N as thread count.",
+       optional => 1,
+       default => 0,
+    },
+    quiet => {
+       type => 'boolean',
+       description => "Be quiet.",
+       optional => 1,
+       default => 0,
+    },
+    mode => {
+       type => 'string',
+       description => "Backup mode.",
+       optional => 1,
+       default => 'snapshot',
+       enum => [ 'snapshot', 'suspend', 'stop' ],
+    },
+    exclude => {
+       type => 'string', format => 'pve-vmid-list',
+       description => "Exclude specified guest systems (assumes --all)",
+       optional => 1,
+    },
+    'exclude-path' => {
+       type => 'string', format => 'string-alist',
+       description => "Exclude certain files/directories (shell globs).",
+       optional => 1,
+    },
+    mailto => {
+       type => 'string', format => 'string-list',
+       description => "Comma-separated list of email addresses that should" .
+           " receive email notifications.",
+       optional => 1,
+    },
+    mailnotification => {
+       type => 'string',
+       description => "Specify when to send an email",
+       optional => 1,
+       enum => [ 'always', 'failure' ],
+       default => 'always',
+    },
+    tmpdir => {
+       type => 'string',
+       description => "Store temporary files to specified directory.",
+       optional => 1,
+    },
+    dumpdir => {
+       type => 'string',
+       description => "Store resulting files to specified directory.",
+       optional => 1,
+    },
+    script => {
+       type => 'string',
+       description => "Use specified hook script.",
+       optional => 1,
+    },
+    storage => get_standard_option('pve-storage-id', {
+       description => "Store resulting file to this storage.",
+       completion => \&complete_backup_storage,
+       optional => 1,
+    }),
+    stop => {
+       type => 'boolean',
+       description => "Stop runnig backup jobs on this host.",
+       optional => 1,
+       default => 0,
+    },
+    size => {
+       type => 'integer',
+       description => "Unused, will be removed in a future release.",
+       optional => 1,
+       minimum => 500,
+       default => 1024,
+    },
+    bwlimit => {
+       type => 'integer',
+       description => "Limit I/O bandwidth (KBytes per second).",
+       optional => 1,
+       minimum => 0,
+       default => 0,
+    },
+    ionice => {
+       type => 'integer',
+       description => "Set CFQ ionice priority.",
+       optional => 1,
+       minimum => 0,
+       maximum => 8,
+       default => 7,
+    },
+    lockwait => {
+       type => 'integer',
+       description => "Maximal time to wait for the global lock (minutes).",
+       optional => 1,
+       minimum => 0,
+       default => 3*60, # 3 hours
+    },
+    stopwait => {
+       type => 'integer',
+       description => "Maximal time to wait until a guest system is stopped (minutes).",
+       optional => 1,
+       minimum => 0,
+       default => 10, # 10 minutes
+    },
+    maxfiles => {
+       type => 'integer',
+       description => "Maximal number of backup files per guest system.",
+       optional => 1,
+       minimum => 1,
+       default => 1,
+    },
+    remove => {
+       type => 'boolean',
+       description => "Remove old backup files if there are more than 'maxfiles' backup files.",
+       optional => 1,
+       default => 1,
+    },
+};
+
 # Load available plugins
 my @pve_vzdump_classes = qw(PVE::VZDump::QemuServer PVE::VZDump::LXC);
 foreach my $plug (@pve_vzdump_classes) {
@@ -84,7 +237,7 @@ sub run_command {
 sub storage_info {
     my $storage = shift;
 
-    my $cfg = cfs_read_file('storage.cfg');
+    my $cfg = PVE::Storage::config();
     my $scfg = PVE::Storage::storage_config($cfg, $storage);
     my $type = $scfg->{type};
  
@@ -181,73 +334,32 @@ sub read_vzdump_defaults {
 
     my $fn = "/etc/vzdump.conf";
 
-    my $res = {
-       bwlimit => 0,
-       ionice => 7,
-       size => 1024,
-       lockwait => 3*60, # 3 hours
-       stopwait => 10, # 10 minutes
-       mode => 'snapshot',
-       maxfiles => 1, 
+    my $defaults = {
+       map {
+           my $default = $confdesc->{$_}->{default};
+            defined($default) ? ($_ => $default) : ()
+       } keys %$confdesc
     };
 
-    my $fh = IO::File->new ("<$fn");
-    return $res if !$fh;
-    
-    my $line;
-    while (defined ($line = <$fh>)) {
-       next if $line =~ m/^\s*$/;
-       next if $line =~ m/^\#/;
-
-       if ($line =~ m/tmpdir:\s*(.*\S)\s*$/) {
-           $res->{tmpdir} = $1;
-       } elsif ($line =~ m/dumpdir:\s*(.*\S)\s*$/) {
-           $res->{dumpdir} = $1;
-       } elsif ($line =~ m/storage:\s*(\S+)\s*$/) {
-           $res->{storage} = $1;
-       } elsif ($line =~ m/script:\s*(.*\S)\s*$/) {
-           $res->{script} = $1;
-       } elsif ($line =~ m/bwlimit:\s*(\d+)\s*$/) {
-           $res->{bwlimit} = int($1);
-       } elsif ($line =~ m/ionice:\s*([0-8])\s*$/) {
-           $res->{ionice} = int($1);
-       } elsif ($line =~ m/lockwait:\s*(\d+)\s*$/) {
-           $res->{lockwait} = int($1);
-       } elsif ($line =~ m/stopwait:\s*(\d+)\s*$/) {
-           $res->{stopwait} = int($1);
-       } elsif ($line =~ m/stop:\s*(\d+)\s*$/) {
-           $res->{stop} = int($1);
-       } elsif ($line =~ m/size:\s*(\d+)\s*$/) {
-           $res->{size} = int($1);
-       } elsif ($line =~ m/maxfiles:\s*(\d+)\s*$/) {
-           $res->{maxfiles} = int($1);
-       } elsif ($line =~ m/exclude-path:\s*(.*)\s*$/) {
-           $res->{'exclude-path'} = PVE::Tools::split_args($1); 
-       } elsif ($line =~ m/mode:\s*(stop|snapshot|suspend)\s*$/) {
-           $res->{mode} = $1;
-       } else {
-           debugmsg ('warn', "unable to parse configuration file '$fn' - error at line " . $., undef, 1);
-       }
+    my $raw;
+    eval { $raw = PVE::Tools::file_get_contents($fn); };
+    return $defaults if $@;
 
+    my $conf_schema = { type => 'object', properties => $confdesc, };
+    my $res = PVE::JSONSchema::parse_config($conf_schema, $fn, $raw);
+    if (my $excludes = $res->{'exclude-path'}) {
+       $res->{'exclude-path'} = PVE::Tools::split_args($excludes);
     }
-    close ($fh);
-
-    return $res;
-}
-
-
-sub find_add_exclude {
-    my ($self, $excltype, $value) = @_;
-
-    if (($excltype eq '-regex') || ($excltype eq '-files')) {
-       $value = "\.$value";
+    if (defined($res->{mailto})) {
+       my @mailto = PVE::Tools::split_list($res->{mailto});
+       $res->{mailto} = [ @mailto ];
     }
 
-    if ($excltype eq '-files') {
-       push @{$self->{findexcl}}, "'('", '-not', '-type', 'd', '-regex' , "'$value'", "')'", '-o';
-    } else {
-       push @{$self->{findexcl}}, "'('", $excltype , "'$value'", '-prune', "')'", '-o';
+    foreach my $key (keys %$defaults) {
+       $res->{$key} = $defaults->{$key} if !defined($res->{$key});
     }
+
+    return $res;
 }
 
 sub sendmail {
@@ -284,91 +396,45 @@ sub sendmail {
     my $hostname = `hostname -f` || PVE::INotify::nodename();
     chomp $hostname;
 
-    my $boundary = "----_=_NextPart_001_".int(time).$$;
-
-    my $rcvrarg = '';
-    foreach my $r (@$mailto) {
-       $rcvrarg .= " '$r'";
-    }
-    my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
-    my $mailfrom = $dcconf->{email_from} || "root";
-
-    open (MAIL,"|sendmail -B 8BITMIME -f $mailfrom $rcvrarg") || 
-       die "unable to open 'sendmail' - $!";
-
-    my $rcvrtxt = join (', ', @$mailto);
-
-    print MAIL "Content-Type: multipart/alternative;\n";
-    print MAIL "\tboundary=\"$boundary\"\n";
-    print MAIL "MIME-Version: 1.0\n";
-
-    print MAIL "FROM: vzdump backup tool <$mailfrom>\n";
-    print MAIL "TO: $rcvrtxt\n";
-    print MAIL "SUBJECT: vzdump backup status ($hostname) : $stat\n";
-    print MAIL "\n";
-    print MAIL "This is a multi-part message in MIME format.\n\n";
-    print MAIL "--$boundary\n";
-
-    print MAIL "Content-Type: text/plain;\n";
-    print MAIL "\tcharset=\"UTF8\"\n";
-    print MAIL "Content-Transfer-Encoding: 8bit\n";
-    print MAIL "\n";
-
     # text part
-
-    my $fill = '  '; # Avoid The Remove Extra Line Breaks Issue (MS Outlook)
-
-    print MAIL sprintf ("${fill}%-10s %-6s %10s %10s  %s\n", qw(VMID STATUS TIME SIZE FILENAME));
+    my $text = sprintf ("%-10s %-6s %10s %10s  %s\n", qw(VMID STATUS TIME SIZE FILENAME));
     foreach my $task (@$tasklist) {
        my $vmid = $task->{vmid};
        if  ($task->{state} eq 'ok') {
 
-           print MAIL sprintf ("${fill}%-10s %-6s %10s %10s  %s\n", $vmid, 
-                               $task->{state}, 
+           $text .= sprintf ("%-10s %-6s %10s %10s  %s\n", $vmid,
+                               $task->{state},
                                format_time($task->{backuptime}),
                                format_size ($task->{size}),
                                $task->{tarfile});
        } else {
-           print MAIL sprintf ("${fill}%-10s %-6s %10s %8.2fMB  %s\n", $vmid, 
-                               $task->{state}, 
+           $text .= sprintf ("%-10s %-6s %10s %8.2fMB  %s\n", $vmid,
+                               $task->{state},
                                format_time($task->{backuptime}),
                                0, '-');
        }
     }
-    print MAIL "${fill}\n";
-    print MAIL "${fill}Detailed backup logs:\n";
-    print MAIL "${fill}\n";
-    print MAIL "$fill$cmdline\n";
-    print MAIL "${fill}\n";
+
+    $text .= "Detailed backup logs:\n\n";
+    $text .= "$cmdline\n\n";
 
     foreach my $task (@$tasklist) {
        my $vmid = $task->{vmid};
        my $log = $task->{tmplog};
        if (!$log) {
-           print MAIL "${fill}$vmid: no log available\n\n";
+           $text .= "$vmid: no log available\n\n";
            next;
        }
        open (TMP, "$log");
-       while (my $line = <TMP>) { print MAIL encode8bit ("${fill}$vmid: $line"); }
+       while (my $line = <TMP>) { $text .= encode8bit ("$vmid: $line"); }
        close (TMP);
-       print MAIL "${fill}\n";
+       $text .= "\n";
     }
 
-    # end text part
-    print MAIL "\n--$boundary\n";
-
-    print MAIL "Content-Type: text/html;\n";
-    print MAIL "\tcharset=\"UTF8\"\n";
-    print MAIL "Content-Transfer-Encoding: 8bit\n";
-    print MAIL "\n";
-
     # html part
-
-    print MAIL "<html><body>\n";
-
-    print MAIL "<table border=1 cellpadding=3>\n";
-
-    print MAIL "<tr><td>VMID<td>NAME<td>STATUS<td>TIME<td>SIZE<td>FILENAME</tr>\n";
+    my $html = "<html><body>\n";
+    $html .= "<table border=1 cellpadding=3>\n";
+    $html .= "<tr><td>VMID<td>NAME<td>STATUS<td>TIME<td>SIZE<td>FILENAME</tr>\n";
 
     my $ssize = 0;
 
@@ -380,56 +446,54 @@ sub sendmail {
 
            $ssize += $task->{size};
 
-           print MAIL sprintf ("<tr><td>%s<td>%s<td>OK<td>%s<td align=right>%s<td>%s</tr>\n", 
+           $html .= sprintf ("<tr><td>%s<td>%s<td>OK<td>%s<td align=right>%s<td>%s</tr>\n",
                                $vmid, $name,
                                format_time($task->{backuptime}),
                                format_size ($task->{size}),
                                escape_html ($task->{tarfile}));
        } else {
-           print MAIL sprintf ("<tr><td>%s<td>%s<td><font color=red>FAILED<td>%s<td colspan=2>%s</tr>\n",
-                               $vmid, $name, format_time($task->{backuptime}), 
+           $html .= sprintf ("<tr><td>%s<td>%s<td><font color=red>FAILED<td>%s<td colspan=2>%s</tr>\n",
+                               $vmid, $name, format_time($task->{backuptime}),
                                escape_html ($task->{msg}));
        }
     }
 
-    print MAIL sprintf ("<tr><td align=left colspan=3>TOTAL<td>%s<td>%s<td></tr>",
+    $html .= sprintf ("<tr><td align=left colspan=3>TOTAL<td>%s<td>%s<td></tr>",
  format_time ($totaltime), format_size ($ssize));
 
-    print MAIL "</table><br><br>\n";
-    print MAIL "Detailed backup logs:<br>\n";
-    print MAIL "<br>\n";
-    print MAIL "<pre>\n";
-    print MAIL escape_html($cmdline) . "\n";
-    print MAIL "\n";
+    $html .= "</table><br><br>\n";
+    $html .= "Detailed backup logs:<br /><br />\n";
+    $html .= "<pre>\n";
+    $html .= escape_html($cmdline) . "\n\n";
 
     foreach my $task (@$tasklist) {
        my $vmid = $task->{vmid};
        my $log = $task->{tmplog};
        if (!$log) {
-           print MAIL "$vmid: no log available\n\n";
+           $html .= "$vmid: no log available\n\n";
            next;
        }
        open (TMP, "$log");
        while (my $line = <TMP>) {
            if ($line =~ m/^\S+\s\d+\s+\d+:\d+:\d+\s+(ERROR|WARN):/) {
-               print MAIL encode8bit ("$vmid: <font color=red>". 
-                                      escape_html ($line) . "</font>"); 
+               $html .= encode8bit ("$vmid: <font color=red>".
+                                      escape_html ($line) . "</font>");
            } else {
-               print MAIL encode8bit ("$vmid: " . escape_html ($line)); 
+               $html .= encode8bit ("$vmid: " . escape_html ($line));
            }
        }
        close (TMP);
-       print MAIL "\n";
+       $html .= "\n";
     }
-    print MAIL "</pre>\n";
+    $html .= "</pre></body></html>\n";
+    # end html part
 
-    print MAIL "</body></html>\n";
+    my $subject = "vzdump backup status ($hostname) : $stat";
 
-    # end html part
-    print MAIL "\n--$boundary--\n";
+    my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
+    my $mailfrom = $dcconf->{email_from} || "root";
 
-    close(MAIL);
+    PVE::Tools::sendmail($mailto, $subject, $text, $html, $mailfrom, "vzdump backup tool");
 };
 
 sub new {
@@ -460,6 +524,7 @@ sub new {
     $opts->{remove} = 1 if !defined($opts->{remove});
 
     foreach my $k (keys %$defaults) {
+       next if $k eq 'exclude-path'; # dealt with separately
        if ($k eq 'dumpdir' || $k eq 'storage') {
            $opts->{$k} = $defaults->{$k} if !defined ($opts->{dumpdir}) &&
                !defined ($opts->{storage});
@@ -474,28 +539,20 @@ sub new {
     $skiplist = [] if !$skiplist;
     my $self = bless { cmdline => $cmdline, opts => $opts, skiplist => $skiplist };
 
-    #always skip '.'
-    push @{$self->{findexcl}}, "'('", '-regex' , "'^\\.\$'", "')'", '-o';
-
-    $self->find_add_exclude ('-type', 's'); # skip sockets
-
+    my $findexcl = $self->{findexcl} = [];
     if ($defaults->{'exclude-path'}) {
-       foreach my $path (@{$defaults->{'exclude-path'}}) {
-           $self->find_add_exclude ('-regex', $path);
-       }
+       push @$findexcl, @{$defaults->{'exclude-path'}};
     }
 
     if ($opts->{'exclude-path'}) {
-       foreach my $path (@{$opts->{'exclude-path'}}) {
-           $self->find_add_exclude ('-regex', $path);
-       }
+       push @$findexcl, @{$opts->{'exclude-path'}};
     }
 
     if ($opts->{stdexcludes}) {
-       $self->find_add_exclude ('-files', '/var/log/.+');
-       $self->find_add_exclude ('-regex', '/tmp/.+');
-       $self->find_add_exclude ('-regex', '/var/tmp/.+');
-       $self->find_add_exclude ('-regex', '/var/run/.+pid');
+       push @$findexcl, '/var/log/?*',
+                        '/tmp/?*',
+                        '/var/tmp/?*',
+                        '/var/run/?*.pid';
     }
 
     foreach my $p (@plugins) {
@@ -530,33 +587,6 @@ sub new {
 
 }
 
-sub get_lvm_mapping {
-
-    my $devmapper;
-
-    my $cmd = ['lvs', '--units', 'm', '--separator', ':', '--noheadings',
-              '-o', 'vg_name,lv_name,lv_size' ];
-
-    my $parser = sub {
-       my $line = shift;
-       if ($line =~ m|^\s*(\S+):(\S+):(\d+(\.\d+))[Mm]$|) {
-           my $vg = $1;
-           my $lv = $2;
-           $devmapper->{"/dev/$vg/$lv"} = [$vg, $lv];
-           my $qlv = $lv;
-           $qlv =~ s/-/--/g;
-           my $qvg = $vg;
-           $qvg =~ s/-/--/g;
-           $devmapper->{"/dev/mapper/$qvg-$qlv"} = [$vg, $lv];
-       }                       
-    };
-
-    eval { PVE::Tools::run_command($cmd, errfunc => sub {}, outfunc => $parser); };
-    warn $@ if $@;
-
-    return $devmapper;
-}
-
 sub get_mount_info {
     my ($dir) = @_;
 
@@ -584,22 +614,6 @@ sub get_mount_info {
     return $res;
 }
 
-sub get_lvm_device {
-    my ($dir, $mapping) = @_;
-
-    my $info = get_mount_info($dir);
-
-    return undef if !$info;
-   
-    my $dev = $info->{device};
-
-    my ($vg, $lv);
-
-    ($vg, $lv) = @{$mapping->{$dev}} if defined $mapping->{$dev};
-
-    return wantarray ? ($dev, $info->{mountpoint}, $vg, $lv, $info->{fstype}) : $dev;
-}
-
 sub getlock {
     my ($self, $upid) = @_;
 
@@ -678,14 +692,22 @@ sub run_hook_script {
 }
 
 sub compressor_info {
-    my ($opt_compress) = @_;
+    my ($opts) = @_;
+    my $opt_compress = $opts->{compress};
 
     if (!$opt_compress || $opt_compress eq '0') {
        return undef;
     } elsif ($opt_compress eq '1' || $opt_compress eq 'lzo') {
        return ('lzop', 'lzo');
     } elsif ($opt_compress eq 'gzip') {
-       return ('gzip', 'gz');
+       if ($opts->{pigz} > 0) {
+           # As default use int((#cores + 1)/2), we need #cores+1 for the case that #cores = 1
+           my $cores = POSIX::sysconf(84);
+           my $pigz_threads = ($opts->{pigz} > 1) ? $opts->{pigz} : int(($cores + 1)/2);
+           return ("pigz -p ${pigz_threads}", 'gz');
+       } else {
+           return ('gzip', 'gz');
+       }
     } else {
        die "internal error - unknown compression option '$opt_compress'";
     }
@@ -726,6 +748,15 @@ sub exec_backup_task {
     eval {
        die "unable to find VM '$vmid'\n" if !$plugin;
 
+       # for now we deny backups of a running ha managed service in *stop* mode
+       # as it interferes with the HA stack (enabled services should not stop).
+       if ($opts->{mode} eq 'stop' &&
+           PVE::HA::Config::vm_is_ha_managed($vmid, 'enabled'))
+       {
+           die "Cannot execute a backup with stop mode on a HA managed and".
+               " enabled Service. Use snapshot mode or disable the Service.\n";
+       }
+
        my $vmtype = $plugin->type();
 
        my $tmplog = "$logdir/$vmtype-$vmid.log";
@@ -748,7 +779,7 @@ sub exec_backup_task {
        my $logfile = $task->{logfile} = "$opts->{dumpdir}/$basename.log";
 
        my $ext = $vmtype eq 'qemu' ? '.vma' : '.tar';
-       my ($comp, $comp_ext) = compressor_info($opts->{compress});
+       my ($comp, $comp_ext) = compressor_info($opts);
        if ($comp && $comp_ext) {
            $ext .= ".${comp_ext}";
        }
@@ -872,6 +903,7 @@ sub exec_backup_task {
                $cleanup->{resume} = 0;
                $self->run_hook_script('pre-restart', $task, $logfd);
                $plugin->resume_vm($task, $vmid);
+               $self->run_hook_script('post-restart', $task, $logfd);
                my $delay = time () - $vmstoptime;
                debugmsg('info', "vm is online again after $delay seconds", $logfd);
            }
@@ -903,6 +935,8 @@ sub exec_backup_task {
                debugmsg ('info', "vm is online again after $delay seconds", $logfd);
            }
 
+           $self->run_hook_script ('post-restart', $task, $logfd);
+
        } else {
            die "internal error - unknown mode '$mode'\n";
        }
@@ -958,8 +992,11 @@ sub exec_backup_task {
            warn $@ if $@;
        }
 
-       eval { $plugin->cleanup ($task, $vmid) };
-       warn $@ if $@;
+       if (defined($task->{mode})) { 
+           # only call cleanup when necessary (when prepare was executed)
+           eval { $plugin->cleanup ($task, $vmid) };
+           warn $@ if $@;
+       }
 
        eval { $plugin->set_logfd (undef); };
        warn $@ if $@;
@@ -976,7 +1013,8 @@ sub exec_backup_task {
                        debugmsg ('info', "restarting vm", $logfd);
                        $plugin->start_vm ($task, $vmid);
                    }
-               } 
+               }
+               $self->run_hook_script ('post-restart', $task, $logfd);
            };
            my $err = $@;
            if ($err) {
@@ -1094,139 +1132,6 @@ sub exec_backup {
     unlink $pidfile;
 }
 
-my $confdesc = {
-    vmid => {
-       type => 'string', format => 'pve-vmid-list',            
-       description => "The ID of the VM you want to backup.",
-       optional => 1,
-    },
-    node => get_standard_option('pve-node', { 
-       description => "Only run if executed on this node.",
-       optional => 1,
-    }),
-    all => {
-       type => 'boolean',
-       description => "Backup all known VMs on this host.",
-       optional => 1,
-       default => 0,
-    },
-    stdexcludes => {
-       type => 'boolean',
-       description => "Exclude temorary files and logs.",
-       optional => 1,
-       default => 1,
-    },
-    compress => {
-       type => 'string',
-       description => "Compress dump file.",
-       optional => 1,
-       enum => ['0', '1', 'gzip', 'lzo'],
-       default => 'lzo',
-    },
-    quiet => {
-       type => 'boolean',
-       description => "Be quiet.",
-       optional => 1,
-       default => 0,
-    },
-    mode => {
-       type => 'string',
-       description => "Backup mode.",
-       optional => 1,
-       default => 'stop',
-       enum => [ 'snapshot', 'suspend', 'stop' ],
-    },
-    exclude => {
-       type => 'string', format => 'pve-vmid-list',
-       description => "exclude specified VMs (assumes --all)",
-       optional => 1,
-    },
-    'exclude-path' => {
-       type => 'string', format => 'string-alist',
-       description => "exclude certain files/directories (regex).",
-       optional => 1,
-    },
-    mailto => {
-       type => 'string', format => 'string-list',
-       description => "",
-       optional => 1,
-    },
-    mailnotification => {
-        type => 'string',
-        description => "Specify when to send an email",
-        optional => 1,
-        enum => [ 'always', 'failure' ],
-        default => 'always',
-    },
-    tmpdir => {
-       type => 'string',
-       description => "Store temporary files to specified directory.",
-       optional => 1,
-    },
-    dumpdir => {
-       type => 'string',
-       description => "Store resulting files to specified directory.",
-       optional => 1,
-    },
-    script => {
-       type => 'string',
-       description => "Use specified hook script.",
-       optional => 1,
-    },
-    storage => get_standard_option('pve-storage-id', {
-       description => "Store resulting file to this storage.",
-       optional => 1,
-    }),
-    stop => {
-       type => 'boolean',
-       description => "Stop runnig backup jobs on this host.",
-       optional => 1,
-       default => 0,
-    },
-    size => {
-       type => 'integer',
-       description => "LVM snapshot size in MB.",
-       optional => 1,
-       minimum => 500,
-    },
-    bwlimit => {
-       type => 'integer',
-       description => "Limit I/O bandwidth (KBytes per second).",
-       optional => 1,
-       minimum => 0,
-    },
-    ionice => {
-       type => 'integer',
-       description => "Set CFQ ionice priority.",
-       optional => 1,
-       minimum => 0,
-       maximum => 8,
-    },
-    lockwait => {
-       type => 'integer',
-       description => "Maximal time to wait for the global lock (minutes).",
-       optional => 1,
-       minimum => 0,
-    },
-    stopwait => {
-       type => 'integer',
-       description => "Maximal time to wait until a VM is stopped (minutes).",
-       optional => 1,
-       minimum => 0,
-    },
-    maxfiles => {
-       type => 'integer',
-       description => "Maximal number of backup files per VM.",
-       optional => 1,
-       minimum => 1,
-    },
-    remove => {
-       type => 'boolean',
-       description => "Remove old backup files if there are more than 'maxfiles' backup files.",
-       optional => 1,
-       default => 1,
-    },
-};
 
 sub option_exists {
     my $key = shift;
@@ -1255,6 +1160,10 @@ sub verify_vzdump_parameters {
 
     $param->{all} = 1 if defined($param->{exclude});
 
+    warn "option 'size' is deprecated and will be removed in a future " .
+        "release, please update your script/configuration!\n"
+       if defined($param->{size});
+
     return if !$check_missing;
 
     raise_param_exc({ vmid => "property is missing"})
@@ -1293,7 +1202,8 @@ sub command_line {
     }
 
     foreach my $p (keys %$param) {
-       next if $p eq 'id' || $p eq 'vmid' || $p eq 'starttime' || $p eq 'dow' || $p eq 'stdout';
+       next if $p eq 'id' || $p eq 'vmid' || $p eq 'starttime' ||
+               $p eq 'dow' || $p eq 'stdout' || $p eq 'enabled';
        my $v = $param->{$p};
        my $pd = $confdesc->{$p} || die "no such vzdump option '$p'\n";
        if ($p eq 'exclude-path') {
@@ -1308,4 +1218,23 @@ sub command_line {
     return $cmd;
 }
 
+# bash completion helpers
+sub complete_backup_storage {
+
+    my $cfg = PVE::Storage::config();
+    my $ids = $cfg->{ids};
+
+    my $nodename = PVE::INotify::nodename();
+
+    my $res = [];
+    foreach my $sid (keys %$ids) {
+       my $scfg = $ids->{$sid};
+       next if !PVE::Storage::storage_check_enabled($cfg, $sid, $nodename, 1);
+       next if !$scfg->{content}->{backup};
+       push @$res, $sid;
+    }
+
+    return $res;
+}
+
 1;