Bugs fixed, errors correctly logged, rotation enabled, doc added
This commit is contained in:
parent
2544a481b8
commit
5e518fb64e
|
@ -20,6 +20,7 @@ datacenter => 'datacenter1',
|
|||
backup_datastore => 'backups',
|
||||
|
||||
# The local directory where backups datastore folder is mounted
|
||||
# If it's mounted via NFS you have to disable caching for the mount
|
||||
local_backup_dir => '/mnt/vm-backups',
|
||||
|
||||
# Backup jobs
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
vn-vmware (1.0.11) stable; urgency=low
|
||||
vn-vmware (1.0.12) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@ MAILTO="sysadmin@verdnatura.es"
|
|||
00 05 01 * * root vn-vmware.pl --operation clone-job --job monthlyDb
|
||||
|
||||
00 03 * * * root vn-vmware.pl --operation backup-job --job db
|
||||
30 00 * * sat root vn-vmware.pl --operation backup-job --job friday
|
||||
30 00 * * sun root vn-vmware.pl --operation backup-job --job saturday
|
||||
30 00 * * mon root vn-vmware.pl --operation backup-job --job sunday
|
||||
00 00 * * sat root vn-vmware.pl --operation backup-job --job friday
|
||||
00 00 * * sun root vn-vmware.pl --operation backup-job --job saturday
|
||||
00 00 * * mon root vn-vmware.pl --operation backup-job --job sunday
|
||||
|
|
22
vn-vmware.pl
22
vn-vmware.pl
|
@ -126,6 +126,7 @@ my %opts = (
|
|||
|
||||
Opts::add_options(%opts);
|
||||
Opts::parse();
|
||||
# FIXME: When enabled, asks for user and password
|
||||
#Opts::validate();
|
||||
|
||||
my $operation = Opts::get_option('operation');
|
||||
|
@ -194,8 +195,12 @@ sub log_message {
|
|||
sub log_error {
|
||||
my ($error) = @_;
|
||||
|
||||
if ($error->isa('SOAP::Fault')) {
|
||||
$error = $error->faultcode.": ".$error->faultString."\n";
|
||||
if ($error->isa('SoapFault')) {
|
||||
my $detail = ref $error->detail;
|
||||
$error = "SoapFault: $detail: $error->{fault_string}";
|
||||
}
|
||||
unless (substr($error, -1) eq "\n") {
|
||||
$error .= "\n";
|
||||
}
|
||||
|
||||
print color('red');
|
||||
|
@ -223,6 +228,7 @@ if ($log_fh) {
|
|||
}
|
||||
|
||||
sub main {
|
||||
|
||||
my $vcenter_host = $config{hostname};
|
||||
my $username = $config{user};
|
||||
|
||||
|
@ -247,6 +253,9 @@ sub main {
|
|||
|
||||
log_message "Connected to $vcenter_host.";
|
||||
|
||||
my $about = Vim::get_service_content()->about;
|
||||
log_message "Version: $about->{apiType} $about->{version}";
|
||||
|
||||
eval {
|
||||
unless ($operation) {
|
||||
die "Operation not defined.";
|
||||
|
@ -428,11 +437,17 @@ sub backup_machine() {
|
|||
my $disk_file = basename($disk_path);
|
||||
log_message "Copying virtual disk file: $disk_path";
|
||||
|
||||
# XXX: Not implemented by Perl vSphere SDK
|
||||
#my $disk_spec = VirtualDiskSpec->new(
|
||||
# adapterType => 'busLogic',
|
||||
# diskType => 'thin'
|
||||
#);
|
||||
$vdm->CopyVirtualDisk(
|
||||
sourceName => $disk_path,
|
||||
sourceDatacenter => $dc,
|
||||
destName => "$ds_tmp_dir/$disk_file",
|
||||
destDatacenter => $dc
|
||||
#destSpec => $disk_spec
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +532,7 @@ sub rotate_backup() {
|
|||
}
|
||||
foreach my $deleteFile (@delete_files) {
|
||||
log_message "Removing $deleteFile (Not done until script is tested for a while).";
|
||||
#unlink $deleteFile;
|
||||
unlink $deleteFile;
|
||||
}
|
||||
|
||||
if (scalar(@delete_files) == 0) {
|
||||
|
@ -665,7 +680,6 @@ sub clone_machine {
|
|||
);
|
||||
|
||||
if (not($nic_type ~~ @nic_classes)) {
|
||||
Util::disconnect();
|
||||
die "Unable to retrieve NIC type.";
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue