Improved fault tolerance & logging
This commit is contained in:
parent
42ad086d6a
commit
2e18e252b4
|
@ -1,4 +1,4 @@
|
|||
vn-vmware (1.0.18) stable; urgency=low
|
||||
vn-vmware (1.0.19) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
15
vn-vmware.pl
15
vn-vmware.pl
|
@ -11,7 +11,6 @@ use VMware::VIExt;
|
|||
use Time::Piece;
|
||||
use Time::Seconds;
|
||||
use File::Path;
|
||||
use Net::OpenSSH;
|
||||
use Sys::CPU;
|
||||
use Term::ANSIColor;
|
||||
use IO::Handle;
|
||||
|
@ -220,7 +219,6 @@ if ($log_fh) {
|
|||
}
|
||||
|
||||
sub main {
|
||||
|
||||
my $vcenter_host = $config{hostname};
|
||||
my $username = $config{user};
|
||||
|
||||
|
@ -399,6 +397,10 @@ sub backup_machine() {
|
|||
);
|
||||
|
||||
eval {
|
||||
if (-e $local_tmp_dir) {
|
||||
die "Local backup directory is not accessible: $local_tmp_dir";
|
||||
}
|
||||
|
||||
my $vm_path_name = $vm->config->files->vmPathName;
|
||||
log_message "Copying machine configuration file: $vm_path_name";
|
||||
|
||||
|
@ -455,7 +457,7 @@ sub backup_machine() {
|
|||
my $tar_status = system($tar_command);
|
||||
|
||||
unless ($tar_status == 0) {
|
||||
die "An error occurred when trying to compress the file.";
|
||||
die "An error occurred when trying to compress '$vm_name' machine files.";
|
||||
}
|
||||
};
|
||||
my $err = $@;
|
||||
|
@ -467,8 +469,11 @@ sub backup_machine() {
|
|||
$vm->RemoveAllSnapshots();
|
||||
}
|
||||
|
||||
log_message "Removing temporary directory: $local_tmp_dir";
|
||||
rmtree($local_tmp_dir);
|
||||
log_message "Removing temporary directory: $ds_tmp_dir";
|
||||
$file_manager->DeleteDatastoreFile(
|
||||
name => $ds_tmp_dir,
|
||||
datacenter => $dc
|
||||
);
|
||||
|
||||
if ($err) {
|
||||
die $err;
|
||||
|
|
Reference in New Issue