/[smeserver]/rpms/e-smith-backup/sme8/e-smith-backup-2.2.0-workstation-removeTemp.patch
ViewVC logotype

Contents of /rpms/e-smith-backup/sme8/e-smith-backup-2.2.0-workstation-removeTemp.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Sun Jul 7 02:44:02 2013 UTC (11 years, 3 months ago) by wellsi
Branch: MAIN
CVS Tags: e-smith-backup-2_2_0-66_el5_sme, e-smith-backup-2_2_0-67_el5_sme
* Sat Jul 6 2013 Ian Wells <esmith@wellsi.com> 2.2.0-66.sme
- Workstation Backup, remove temporary directoy on success [SME: 5931]
- Refactor directory tree creation and removal.

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-06 19:17:02.000000000 -0700
3 +++ e-smith-backup-2.2.0/root/etc/e-smith/events/actions/workstation-backup-dar 2013-07-06 19:16:39.000000000 -0700
4 @@ -206,20 +206,14 @@
5 }
6
7 $tmpdir = $mntdir . '/tmp_dir';
8 -if (-d "$tmpdir/$id")
9 -{
10 - eval {rmtree("$tmpdir/$id")};
11 - ldie("Error while deleting $tmpdir/$id : $@.\n") if $@;
12 -}
13 -eval {mkpath("$tmpdir/$id")};
14 -ldie("Error while creating $tmpdir/$id : $@. Maybe insufficient rights on backup directory.\n")
15 - if $@;
16 +
17 +&remove_tree ($tmpdir);
18 +&create_tree ("$tmpdir/$id");
19
20 # we know right backup directory is in line and we can write on it.
21 $report .= "Backup temp directory $tmpdir/$id is mounted and is writable \n";
22
23 # rotating backup indicators
24 -
25 ++$incnum;
26 $incnum = 0 if ($dow == $fullday && $incnum > $daysinset-7) ||
27 ($fullday == 7 && $incnum >= $daysinset);
28 @@ -245,8 +239,7 @@
29
30 unless ( -d $setdirname )
31 {
32 - eval {mkpath($setdirname)};
33 - ldie("Can't create $setdirname : $@.\n") if $@;
34 + &create_tree ($setdirname);
35 $report .= "Backup directory $id/$setname created \n";
36 }
37
38 @@ -320,10 +313,8 @@
39 if ($incnum == 0)
40 {
41 $report .= "Rotating backups in a new set $setdirname. \n";
42 - eval {rmtree($setdirname)};
43 - ldie("Error while deleting $setdirname : $@.\n") if $@;
44 - eval {mkpath("$setdirname")};
45 - ldie("Error while creating $setdirname : $@.\n") if $@;
46 + &remove_tree ($setdirname);
47 + &create_tree ($setdirname);
48 }
49
50 $report .= "Moving backup files to target directory $setdirname \n";
51 @@ -334,8 +325,10 @@
52 unless move($_, $setdirname);
53 }
54
55 -# update dar_manager catalog
56 +# Remove temporary directory as no longer needed
57 +&remove_tree ($tmpdir);
58
59 +# update dar_manager catalog
60 $report .= "Updating catalog\n";
61
62 my %backupfiles = ();
63 @@ -540,3 +533,21 @@
64 close(INPUT);
65 return $code;
66 }
67 +
68 +
69 +sub remove_tree
70 +{
71 + my $tree = shift;
72 + if (-d "$tree")
73 + {
74 + eval {rmtree("$tree")};
75 + ldie("Error while deleting $tree : $@.\n") if $@;
76 + }
77 +}
78 +
79 +sub create_tree
80 +{
81 + my $tree = shift;
82 + eval {mkpath("$tree")};
83 + ldie("Error while creating $tree : $@. Maybe insufficient rights directory.\n") if $@;
84 +}

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed