Fixes: ignore disk, restore dir
gitea/vn-vmware/pipeline/head This commit looks good
Details
gitea/vn-vmware/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c9d438c605
commit
c16fa9184d
|
@ -1,4 +1,4 @@
|
|||
vn-vmware (1.1.24) stable; urgency=low
|
||||
vn-vmware (1.1.25) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
63
vn-vmware.pl
63
vn-vmware.pl
|
@ -615,49 +615,44 @@ sub backup_job() {
|
|||
my $backup_job = $config{backup_jobs}{$job};
|
||||
my @machines = @{$backup_job->{machines}};
|
||||
|
||||
my $default_rotation;
|
||||
my $rotation_name;
|
||||
|
||||
if (exists $backup_job->{rotation}) {
|
||||
$default_rotation = $backup_job->{rotation};
|
||||
$rotation_name = $backup_job->{rotation};
|
||||
} elsif (exists $config{rotation}) {
|
||||
$default_rotation = $config{rotation};
|
||||
$rotation_name = $config{rotation};
|
||||
}
|
||||
|
||||
if (defined ($rotation_name)) {
|
||||
unless (exists $config{rotations}{$rotation_name}) {
|
||||
die "Rotation '$rotation_name' not defined.";
|
||||
}
|
||||
|
||||
my $rotation_cfg = $config{rotations}{$rotation_name};
|
||||
|
||||
if (exists $rotation_cfg->{count}) {
|
||||
$rotation_count = $rotation_cfg->{count};
|
||||
}
|
||||
if (exists $rotation_cfg->{days}) {
|
||||
$rotation_days = $rotation_cfg->{days};
|
||||
}
|
||||
if (exists $rotation_cfg->{archive_regex}) {
|
||||
$archive_regex = $rotation_cfg->{archive_regex};
|
||||
$archive_regex = qr/$archive_regex/;
|
||||
}
|
||||
if (exists $rotation_cfg->{archive_fn}) {
|
||||
$archive_fn = $rotation_cfg->{archive_fn};
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $machine (@machines) {
|
||||
eval {
|
||||
my $rotation_name = $default_rotation;
|
||||
|
||||
if (ref($machine) eq 'HASH') {
|
||||
$vm_name = $machine->{name};
|
||||
$backup_disks = $machine->{disks};
|
||||
|
||||
if (exists $machine->{rotation}) {
|
||||
$rotation_name = $machine->{rotation};
|
||||
}
|
||||
} else {
|
||||
$vm_name = $machine;
|
||||
}
|
||||
|
||||
if (defined ($rotation_name)) {
|
||||
unless (exists $config{rotations}{$rotation_name}) {
|
||||
die "Rotation '$rotation_name' not defined.";
|
||||
}
|
||||
|
||||
my $rotation_cfg = $config{rotations}{$rotation_name};
|
||||
|
||||
if (exists $rotation_cfg->{count}) {
|
||||
$rotation_count = $rotation_cfg->{count};
|
||||
}
|
||||
if (exists $rotation_cfg->{days}) {
|
||||
$rotation_days = $rotation_cfg->{days};
|
||||
}
|
||||
if (exists $rotation_cfg->{archive_regex}) {
|
||||
$archive_regex = $rotation_cfg->{archive_regex};
|
||||
$archive_regex = qr/$archive_regex/;
|
||||
}
|
||||
if (exists $rotation_cfg->{archive_fn}) {
|
||||
$archive_fn = $rotation_cfg->{archive_fn};
|
||||
}
|
||||
$backup_disks = undef;
|
||||
}
|
||||
|
||||
open_machine();
|
||||
|
@ -787,7 +782,10 @@ sub restore_backup() {
|
|||
die "Restore directory doesn't exists: $restore_dir"
|
||||
}
|
||||
|
||||
my $tar_command = "tar xz -C \"$restore_dir\"";
|
||||
my ($end_dir) = fileparse($backup_file, qr/\..*/);
|
||||
my $tar_dir = "$restore_dir/$end_dir";
|
||||
|
||||
my $tar_command = "tar xz -C \"$tar_dir\"";
|
||||
|
||||
if ($backup_file =~ qr/\.gpg$/) {
|
||||
my $gpg_command = "gpg --decrypt --passphrase-file \"$passphrase_file\" --batch --yes \"$backup_file\"";
|
||||
|
@ -798,6 +796,7 @@ sub restore_backup() {
|
|||
|
||||
log_message $tar_command;
|
||||
unless ($test) {
|
||||
mkdir($tar_dir, 0755);
|
||||
my $tar_status = system($tar_command);
|
||||
unless ($tar_status == 0) {
|
||||
die "An error occurred restoring backup $backup_file";
|
||||
|
|
Reference in New Issue