diff -ruN e-smith-backup-2.2.0.old/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.2.0/root/etc/e-smith/events/actions/workstation-backup-dar --- e-smith-backup-2.2.0.old/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-13 12:47:09.000000000 -0700 +++ e-smith-backup-2.2.0/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-13 13:32:08.000000000 -0700 @@ -206,14 +206,6 @@ Verify availability of your backup volume. Stopping the backup now.\n") } -$tmpdir = $mntdir . '/tmp_dir'; - -&remove_tree ("$tmpdir/$id"); -&create_tree ("$tmpdir/$id"); - -# we know right backup directory is in line and we can write on it. -$report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n"; - # rotating backup indicators ++$incnum; $incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) || @@ -243,6 +235,20 @@ &create_tree ($setdirname); $report .= "Backup directory $id/$setname created \n"; } + +if ($deleteearly ne 'true') +{ + $tmpdir = $mntdir . '/tmp_dir'; + + &remove_tree ("$tmpdir/$id"); + &create_tree ("$tmpdir/$id"); + $report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n"; +} +else +{ + $report .= "Backup directory $setdirname is mounted \n"; +} + if ( $incnum == 0 ) { @@ -286,7 +292,6 @@ } $report .= "Backup base file name is $bkname \n"; -$report .= "Making backup in temp directory\n"; # calculate real timeout if we timeout incrementals only. # timeout of 88500 is a security for aborting backup within 24h @@ -295,7 +300,7 @@ { $timeout = 88500; } -$report .= "Using a backup session timeout of : $timeout seconds\n"; +$report .= "Starting the backup with a timeout of : $timeout seconds\n"; # expanding backup configuration file template @@ -311,31 +316,32 @@ &create_tree ($setdirname); } +my $destination = ($deleteearly ne 'true') ? "$tmpdir/$id/$bkname" : "$setdirname/$bkname"; + # Perform the actual backup -my $rc = run_backup(); +my $rc = run_backup($destination); if ($rc != 0 && $rc != 11) { ldie("Error while running dar: $rc"); } -if (($deleteearly ne 'true') && (($incnum == 0))) # Allow delete after backup +if ($deleteearly ne 'true') # Not DeleteEarly so move backup to $setdirname { - &remove_tree ($setdirname); - &create_tree ($setdirname); -} - -$report .= "Moving backup files to target directory $setdirname \n"; - -foreach (bsd_glob("$tmpdir/$id/$bkname*")) -{ - ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!") - unless move($_, $setdirname); + $report .= "Moving backup files to target directory $setdirname \n"; + if ($incnum == 0) + { + &remove_tree ($setdirname); + &create_tree ($setdirname); + } + foreach (bsd_glob("$tmpdir/$id/$bkname*")) + { + ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!") + unless move($_, $setdirname); + } + &remove_tree ("$tmpdir/$id"); } -# Remove temporary directory as no longer needed -&remove_tree ("$tmpdir/$id"); - # update dar_manager catalog $report .= "Updating catalog\n"; @@ -515,12 +521,13 @@ sub run_backup { + my $dest = shift; my $data = undef; my $pid = undef; my $killerpid = undef; eval { - ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$tmpdir/$id/$bkname", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" ); + ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$dest", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" ); if ($pid) { $killerpid = start_dar_killer($pid, $timeout); }