1 |
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 |
2 |
--- e-smith-backup-2.2.0.old/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-13 12:47:09.000000000 -0700 |
3 |
+++ e-smith-backup-2.2.0/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-13 13:32:08.000000000 -0700 |
4 |
@@ -206,14 +206,6 @@ |
5 |
Verify availability of your backup volume. Stopping the backup now.\n") |
6 |
} |
7 |
|
8 |
-$tmpdir = $mntdir . '/tmp_dir'; |
9 |
- |
10 |
-&remove_tree ("$tmpdir/$id"); |
11 |
-&create_tree ("$tmpdir/$id"); |
12 |
- |
13 |
-# we know right backup directory is in line and we can write on it. |
14 |
-$report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n"; |
15 |
- |
16 |
# rotating backup indicators |
17 |
++$incnum; |
18 |
$incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) || |
19 |
@@ -243,6 +235,20 @@ |
20 |
&create_tree ($setdirname); |
21 |
$report .= "Backup directory $id/$setname created \n"; |
22 |
} |
23 |
+ |
24 |
+if ($deleteearly ne 'true') |
25 |
+{ |
26 |
+ $tmpdir = $mntdir . '/tmp_dir'; |
27 |
+ |
28 |
+ &remove_tree ("$tmpdir/$id"); |
29 |
+ &create_tree ("$tmpdir/$id"); |
30 |
+ $report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n"; |
31 |
+} |
32 |
+else |
33 |
+{ |
34 |
+ $report .= "Backup directory $setdirname is mounted \n"; |
35 |
+} |
36 |
+ |
37 |
|
38 |
if ( $incnum == 0 ) |
39 |
{ |
40 |
@@ -286,7 +292,6 @@ |
41 |
} |
42 |
|
43 |
$report .= "Backup base file name is $bkname \n"; |
44 |
-$report .= "Making backup in temp directory\n"; |
45 |
|
46 |
# calculate real timeout if we timeout incrementals only. |
47 |
# timeout of 88500 is a security for aborting backup within 24h |
48 |
@@ -295,7 +300,7 @@ |
49 |
{ |
50 |
$timeout = 88500; |
51 |
} |
52 |
-$report .= "Using a backup session timeout of : $timeout seconds\n"; |
53 |
+$report .= "Starting the backup with a timeout of : $timeout seconds\n"; |
54 |
|
55 |
# expanding backup configuration file template |
56 |
|
57 |
@@ -311,31 +316,32 @@ |
58 |
&create_tree ($setdirname); |
59 |
} |
60 |
|
61 |
+my $destination = ($deleteearly ne 'true') ? "$tmpdir/$id/$bkname" : "$setdirname/$bkname"; |
62 |
+ |
63 |
# Perform the actual backup |
64 |
-my $rc = run_backup(); |
65 |
+my $rc = run_backup($destination); |
66 |
|
67 |
if ($rc != 0 && $rc != 11) |
68 |
{ |
69 |
ldie("Error while running dar: $rc"); |
70 |
} |
71 |
|
72 |
-if (($deleteearly ne 'true') && (($incnum == 0))) # Allow delete after backup |
73 |
+if ($deleteearly ne 'true') # Not DeleteEarly so move backup to $setdirname |
74 |
{ |
75 |
- &remove_tree ($setdirname); |
76 |
- &create_tree ($setdirname); |
77 |
-} |
78 |
- |
79 |
-$report .= "Moving backup files to target directory $setdirname \n"; |
80 |
- |
81 |
-foreach (bsd_glob("$tmpdir/$id/$bkname*")) |
82 |
-{ |
83 |
- ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!") |
84 |
- unless move($_, $setdirname); |
85 |
+ $report .= "Moving backup files to target directory $setdirname \n"; |
86 |
+ if ($incnum == 0) |
87 |
+ { |
88 |
+ &remove_tree ($setdirname); |
89 |
+ &create_tree ($setdirname); |
90 |
+ } |
91 |
+ foreach (bsd_glob("$tmpdir/$id/$bkname*")) |
92 |
+ { |
93 |
+ ldie("Error while moving backup file $_ from temporary dir $tmpdir/$id to $setdirname : $!") |
94 |
+ unless move($_, $setdirname); |
95 |
+ } |
96 |
+ &remove_tree ("$tmpdir/$id"); |
97 |
} |
98 |
|
99 |
-# Remove temporary directory as no longer needed |
100 |
-&remove_tree ("$tmpdir/$id"); |
101 |
- |
102 |
# update dar_manager catalog |
103 |
$report .= "Updating catalog\n"; |
104 |
|
105 |
@@ -515,12 +521,13 @@ |
106 |
|
107 |
sub run_backup |
108 |
{ |
109 |
+ my $dest = shift; |
110 |
my $data = undef; |
111 |
my $pid = undef; |
112 |
my $killerpid = undef; |
113 |
|
114 |
eval { |
115 |
- ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$tmpdir/$id/$bkname", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" ); |
116 |
+ ($pid = open INPUT, "-|", "/usr/bin/dar", "-Q", "--create", "$dest", split(/\|/,$ref), "-B", "/etc/dar/$job.dcf") or ldie("cannot start : $!" ); |
117 |
|
118 |
if ($pid) { |
119 |
$killerpid = start_dar_killer($pid, $timeout); } |