Better session timeout fix, configurable pigz procs, logging improved
This commit is contained in:
parent
58bb759980
commit
3b8838de1d
|
@ -14,6 +14,9 @@ backup_datastore => 'backups',
|
|||
# If it's mounted via NFS you have to disable caching for the mount
|
||||
local_backup_dir => '/mnt/vm-backups',
|
||||
|
||||
# Number of processes used by pigz to compress backups
|
||||
pigz_processes => 1,
|
||||
|
||||
# Backup jobs
|
||||
backup_jobs => {
|
||||
schedule1 => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
vn-vmware (1.0.28) stable; urgency=low
|
||||
vn-vmware (1.0.29) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
MAILFROM="vn-vmware@domain.local"
|
||||
MAILTO="sysadmin@domain.local"
|
||||
|
||||
00 04 * * tue-fri root vn-vmware.pl --operation clone-job --job test
|
||||
00 04 * * tue-fri root vn-vmware.pl --operation test
|
||||
|
|
29
vn-vmware.pl
29
vn-vmware.pl
|
@ -231,6 +231,14 @@ sub main {
|
|||
Util::connect();
|
||||
log_message "Connected to $server.";
|
||||
|
||||
# TODO: Keep session alive on large operations
|
||||
$SIG{ALRM} = sub {
|
||||
alarm(5);
|
||||
my $si_view = Vim::get_service_instance();
|
||||
$si_view->CurrentTime();
|
||||
};
|
||||
alarm(1);
|
||||
|
||||
my $about = Vim::get_service_content()->about;
|
||||
log_message "Version: $about->{apiType} $about->{version}";
|
||||
|
||||
|
@ -274,6 +282,7 @@ sub main {
|
|||
};
|
||||
my $err = $@;
|
||||
|
||||
alarm(0);
|
||||
Util::disconnect();
|
||||
|
||||
if ($err) {
|
||||
|
@ -440,28 +449,30 @@ sub backup_machine() {
|
|||
destDatacenter => $dc
|
||||
#destSpec => $disk_spec
|
||||
);
|
||||
|
||||
# FIXME: Reconnecting because session timeout
|
||||
Util::connect();
|
||||
}
|
||||
}
|
||||
|
||||
log_message "Consolidating and removing snapshots.";
|
||||
$vm->RemoveAllSnapshots();
|
||||
|
||||
my $gzip_cpus = max(1, int(Sys::CPU::cpu_count()) - 1);
|
||||
my $tar_command = "tar -I \"pigz -p $gzip_cpus\" -cf $tar_file -C $local_tmp_dir .";
|
||||
my $pigz_processes;
|
||||
|
||||
log_message "Compressing with Gzip (using $gzip_cpus CPUs) to TAR file.";
|
||||
if (exists $config{pigz_processes}) {
|
||||
$pigz_processes = $config{pigz_processes};
|
||||
} else {
|
||||
$pigz_processes = int(Sys::CPU::cpu_count()) - 2;
|
||||
}
|
||||
|
||||
$pigz_processes = max(1, $pigz_processes);
|
||||
my $tar_command = "tar -I \"pigz -p $pigz_processes\" -cf $tar_file -C $local_tmp_dir .";
|
||||
|
||||
log_message "Compressing with Gzip (using $pigz_processes processes) to TAR file.";
|
||||
log_message $tar_command;
|
||||
my $tar_status = system($tar_command);
|
||||
|
||||
unless ($tar_status == 0) {
|
||||
die "An error occurred when trying to compress '$vm_name' machine files.";
|
||||
}
|
||||
|
||||
# FIXME: Reconnecting because session timeout
|
||||
Util::connect();
|
||||
};
|
||||
my $err = $@;
|
||||
|
||||
|
|
Reference in New Issue