1 |
diff -ruN e-smith-backup-2.4.0.old/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar |
2 |
--- e-smith-backup-2.4.0.old/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-14 15:16:30.000000000 -0700 |
3 |
+++ e-smith-backup-2.4.0/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-14 15:14:05.000000000 -0700 |
4 |
@@ -26,7 +26,7 @@ |
5 |
use esmith::templates; |
6 |
use Time::localtime; |
7 |
use File::Copy; |
8 |
-use File::Path qw(make_path remove_tree mkpath rmtree); |
9 |
+use File::Path qw(make_path remove_tree); |
10 |
use File::Find; |
11 |
use POSIX ":sys_wait_h"; |
12 |
use File::Glob qw(bsd_glob); |
13 |
@@ -114,7 +114,7 @@ |
14 |
} |
15 |
|
16 |
# create the directory mount point if it does not exist |
17 |
-make_path ($mntdir) unless (-d $mntdir); |
18 |
+createTree ($mntdir); |
19 |
|
20 |
# mount the backup directory |
21 |
$err = &dmount($smbhost,$smbshare,$mntdir,$login,$password,$VFSType); |
22 |
@@ -128,14 +128,9 @@ |
23 |
} |
24 |
|
25 |
$tmpdir = $mntdir . '/tmp_dir'; |
26 |
-if (-d "$tmpdir/$id") |
27 |
-{ |
28 |
- eval {rmtree("$tmpdir/$id")}; |
29 |
- ldie("Error while deleting $tmpdir/$id : $@.\n") if $@; |
30 |
-} |
31 |
-eval {mkpath("$tmpdir/$id")}; |
32 |
-ldie("Error while creating $tmpdir/$id : $@. Maybe insufficient rights on backup directory.\n") |
33 |
- if $@; |
34 |
+ |
35 |
+&removeTree ("$tmpdir/$id"); |
36 |
+&createTree ("$tmpdir/$id"); |
37 |
|
38 |
# we know right backup directory is in line and we can write on it. |
39 |
$report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n"; |
40 |
@@ -164,13 +159,7 @@ |
41 |
# if no set directory, make it |
42 |
my $setname = "set" . $setnum; |
43 |
my $setdirname = $mntdir . "/$id/" . $setname; |
44 |
- |
45 |
-unless ( -d $setdirname ) |
46 |
-{ |
47 |
- eval {mkpath($setdirname)}; |
48 |
- ldie("Can't create $setdirname : $@.\n") if $@; |
49 |
- $report .= "Backup directory $id/$setname created \n"; |
50 |
-} |
51 |
+&createTree ($setdirname); |
52 |
|
53 |
if ( $incnum == 0 ) |
54 |
{ |
55 |
@@ -213,7 +202,7 @@ |
56 |
ldie("Not a permitted day for full backup. Aborting...\nNext full backup in $delay days.\n"); |
57 |
} |
58 |
|
59 |
-$report .= "Backup base file name is $bkname \n"; |
60 |
+$report .= "Backup to $bkname in $id/$setname\n"; |
61 |
$report .= "Making backup in temp directory\n"; |
62 |
|
63 |
# calculate real timeout if we timeout incrementals only. |
64 |
@@ -242,10 +231,8 @@ |
65 |
if ($incnum == 0) |
66 |
{ |
67 |
$report .= "Rotating backups in a new set $setdirname. \n"; |
68 |
- eval {rmtree($setdirname)}; |
69 |
- ldie("Error while deleting $setdirname : $@.\n") if $@; |
70 |
- eval {mkpath("$setdirname")}; |
71 |
- ldie("Error while creating $setdirname : $@.\n") if $@; |
72 |
+ &removeTree ($setdirname); |
73 |
+ &createTree ($setdirname); |
74 |
} |
75 |
|
76 |
$report .= "Moving backup files to target directory $setdirname \n"; |
77 |
@@ -256,8 +243,10 @@ |
78 |
unless move($_, $setdirname); |
79 |
} |
80 |
|
81 |
-# update dar_manager catalog |
82 |
+# Remove temporary directory as no longer needed |
83 |
+&removeTree ("$tmpdir/$id"); |
84 |
|
85 |
+# update dar_manager catalog |
86 |
$report .= "Updating catalog\n"; |
87 |
|
88 |
my %backupfiles = (); |
89 |
@@ -523,3 +512,24 @@ |
90 |
return ("Mount of type $VFSType not supported.\n"); |
91 |
} |
92 |
} |
93 |
+ |
94 |
+ |
95 |
+sub removeTree |
96 |
+{ |
97 |
+ my $tree = shift; |
98 |
+ if (-d "$tree") |
99 |
+ { |
100 |
+ eval {remove_tree("$tree")}; |
101 |
+ ldie("Error while deleting $tree : $@.\n") if $@; |
102 |
+ } |
103 |
+} |
104 |
+ |
105 |
+sub createTree |
106 |
+{ |
107 |
+ my $tree = shift; |
108 |
+ if (! -d "$tree") |
109 |
+ { |
110 |
+ eval {make_path("$tree")}; |
111 |
+ ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@; |
112 |
+ } |
113 |
+} |