my $confdesc = {
vmid => {
type => 'string', format => 'pve-vmid-list',
- description => "The ID of the VM you want to backup.",
+ description => "The ID of the guest system you want to backup.",
completion => \&PVE::Cluster::complete_local_vmid,
optional => 1,
},
}),
all => {
type => 'boolean',
- description => "Backup all known VMs on this host.",
+ description => "Backup all known guest systems on this host.",
optional => 1,
default => 0,
},
stdexcludes => {
type => 'boolean',
- description => "Exclude temorary files and logs.",
+ description => "Exclude temporary files and logs.",
optional => 1,
default => 1,
},
description => "Compress dump file.",
optional => 1,
enum => ['0', '1', 'gzip', 'lzo'],
- default => 'lzo',
+ default => '0',
},
pigz=> {
type => "integer",
- description => "Uses pigz instead of gzip when N>0.".
+ 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,
type => 'string',
description => "Backup mode.",
optional => 1,
- default => 'stop',
+ default => 'snapshot',
enum => [ 'snapshot', 'suspend', 'stop' ],
},
exclude => {
type => 'string', format => 'pve-vmid-list',
- description => "exclude specified VMs (assumes --all)",
+ description => "Exclude specified guest systems (assumes --all)",
optional => 1,
},
'exclude-path' => {
type => 'string', format => 'string-alist',
- description => "exclude certain files/directories (shell globs).",
+ description => "Exclude certain files/directories (shell globs).",
optional => 1,
},
mailto => {
},
size => {
type => 'integer',
- description => "LVM snapshot size in MB.",
+ 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',
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 VM is stopped (minutes).",
+ 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 VM.",
+ description => "Maximal number of backup files per guest system.",
optional => 1,
minimum => 1,
+ default => 1,
},
remove => {
type => 'boolean',
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};
my $fn = "/etc/vzdump.conf";
my $defaults = {
- bwlimit => 0,
- ionice => 7,
- size => 1024,
- lockwait => 3*60, # 3 hours
- stopwait => 10, # 10 minutes
- mode => 'snapshot',
- maxfiles => 1,
- pigz => 0,
+ map {
+ my $default = $confdesc->{$_}->{default};
+ defined($default) ? ($_ => $default) : ()
+ } keys %$confdesc
};
my $raw;
}
foreach my $key (keys %$defaults) {
- $res->{$key} = $defaults->{$key} if !$res->{$key};
+ $res->{$key} = $defaults->{$key} if !defined($res->{$key});
}
return $res;
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;
$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 {
push @$findexcl, '/var/log/?*',
'/tmp/?*',
'/var/tmp/?*',
- '/var/run/?*';
+ '/var/run/?*.pid';
}
foreach my $p (@plugins) {
$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"})