/[smeserver]/rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-bz9127-add_lock_feature.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-bz9127-add_lock_feature.patch

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


Revision 1.2 - (hide annotations) (download)
Tue Jul 18 14:37:14 2017 UTC (6 years, 11 months ago) by unnilennium
Branch: MAIN
CVS Tags: e-smith-backup-2_6_0-15_el7_sme, e-smith-backup-2_6_0-21_el7_sme, e-smith-backup-2_6_0-13_el7_sme, e-smith-backup-2_6_0-16_el7_sme, e-smith-backup-2_6_0-28_el7_sme, e-smith-backup-2_6_0-14_el7_sme, e-smith-backup-2_6_0-18_el7_sme, e-smith-backup-2_6_0-24_el7_sme, e-smith-backup-2_6_0-19_el7_sme, e-smith-backup-2_6_0-22_el7_sme, e-smith-backup-2_6_0-27_el7_sme, e-smith-backup-2_6_0-20_el7_sme, e-smith-backup-2_6_0-25_el7_sme, e-smith-backup-2_6_0-17_el7_sme, e-smith-backup-2_6_0-23_el7_sme, e-smith-backup-2_6_0-12_el7_sme, e-smith-backup-2_6_0-26_el7_sme, e-smith-backup-2_6_0-29_el7_sme, HEAD
Changes since 1.1: +67 -0 lines
* Tue Jul 18 2017 Jean-Philipe Pialasse <tests@pialasse.com> 2.6.0-12.sme
- added patch for workstation backup lock [SME: 9127]
- code from Stefano Zamboni <zamboni@mind-at-work.it>

1 unnilennium 1.1 diff -Nur e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith.old/Backup.pm e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith/Backup.pm
2     --- e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith.old/Backup.pm 2017-02-17 20:37:15.000000000 +0100
3     +++ e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith/Backup.pm 2017-04-12 11:41:41.000000000 +0200
4     @@ -12,10 +12,12 @@
5     use File::Copy;
6     use Unix::PasswdFile;
7     use Passwd::Unix;
8     +use esmith::lockfile;
9    
10     use vars qw($VERSION @ISA @EXPORT_OK);
11    
12     use constant ESMITH_RESTORE_CACHE => '/var/cache/e-smith/restore';
13     +use constant ESMITH_BACKUP_LOCK_FILE => "/var/lock/subsys/backup-running";
14    
15     @ISA = qw(Exporter);
16    
17     @@ -531,6 +533,32 @@
18     return $dir =~ m:^/(home/e-smith|noexistingpath): ;
19     }
20    
21     +=head2
22     +
23     +set_lock - set lock before running backup
24     +see bug #9217
25     +
26     +=cut
27     +
28     +sub set_lock
29     +{
30     + return esmith::lockfile::LockFileOrReturn(ESMITH_BACKUP_LOCK_FILE);
31     +}
32     +
33     +
34     +=head2
35     +
36     +remove_lock - remove lock after running backup
37     +
38     +=cut
39     +
40     +sub remove_lock
41     +{
42     + esmith::lockfile::UnlockFile(shift);
43     +}
44     +
45     +
46     +
47     =head1 AUTHOR
48    
49     SME Server Developers <bugs@e-smith.com>
50     diff -Nur e-smith-backup-2.6.0/root/sbin/e-smith.old/do_backup e-smith-backup-2.6.0/root/sbin/e-smith/do_backup
51     --- e-smith-backup-2.6.0/root/sbin/e-smith.old/do_backup 2013-02-13 16:21:37.000000000 +0100
52     +++ e-smith-backup-2.6.0/root/sbin/e-smith/do_backup 2017-04-12 16:18:32.000000000 +0200
53     @@ -23,10 +23,22 @@
54     use strict;
55     use esmith::ConfigDB;
56     use esmith::BackupHistoryDB;
57     +use esmith::Backup;
58     +#use esmith::lockfile;
59     +
60     +# lock file.. see bug 9127
61     +my $backup_lock;
62    
63     $ENV{PATH} = "/sbin/e-smith:/sbin:/bin:/usr/bin";
64    
65     my $conf = esmith::ConfigDB->open || die("Could not open config db\n");
66     +
67     +# set lock.. if not, exit
68     +unless (SetLock()) {
69     + die "Error: failed to create lock file.. is a backup already running?";
70     +}
71     +
72     +
73     my $backup = $conf->get('backup');
74     my $status = $backup->prop('status') || 'disabled';
75     my $program = $backup->prop('Program') || 'flexbackup';
76     @@ -64,6 +76,8 @@
77     $now = time();
78     $backup_rec->set_prop('EndEpochTime', "$now");
79     $backup_rec->set_prop('Result', "$status");
80     +# remove lock
81     +RemoveLock();
82     exit 0;
83    
84     sub bad_exit
85     @@ -74,5 +88,26 @@
86     warn("Backup terminated: $phase failed - status: $status\n");
87     $backup_rec->set_prop('EndEpochTime', "$now");
88     $backup_rec->set_prop('Result', "$phase:$status");
89     + # remove lock
90     + RemoveLock();
91     return $status / 256;
92     }
93     +
94     +# subs to set and remove lock on backup
95     +
96     +sub SetLock
97     +{
98     + print "Setting backup lock file\n";
99     + $backup_lock = esmith::Backup::set_lock;
100     + return $backup_lock;
101     +}
102     +
103     +sub RemoveLock
104     +{
105     + if (defined($backup_lock))
106     + {
107     + print "Removing backup lock file\n";
108     + esmith::Backup::remove_lock($backup_lock);
109     + $backup_lock = undef;
110     + }
111     +}
112     diff -Nur e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith.old/console/perform_backup.pm e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm
113     --- e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith.old/console/perform_backup.pm 2017-04-12 22:20:17.000000000 +0200
114     +++ e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith/console/perform_backup.pm 2017-04-13 18:33:32.000000000 +0200
115     @@ -15,6 +15,9 @@
116    
117     my $EMPTY = q{};
118    
119     +# lock file.. see bug 9127
120     +my $backup_lock;
121     +
122     sub new
123     {
124     my $class = shift;
125     @@ -42,6 +45,26 @@
126    
127     }
128    
129     +# subs to set and remove lock on backup
130     +
131     +sub SetLock
132     +{
133     + print "Setting backup lock file\n";
134     + $backup_lock = esmith::Backup::set_lock;
135     + return $backup_lock;
136     +}
137     +
138     +sub RemoveLock
139     +{
140     + if (defined($backup_lock))
141     + {
142     + print "Removing backup lock file\n";
143     + esmith::Backup::remove_lock($backup_lock);
144     + $backup_lock = undef;
145     + }
146     +}
147     +
148     +
149     sub make_backup_callback
150     {
151     my ($device, $CompressionLevel) = @_;
152     @@ -50,6 +73,11 @@
153     my @backup_list = esmith::Backup->restore_list;
154     my @backup_excludes = esmith::Backup->excludes;
155     my $backup_size = backupSize (@backup_list);
156     +
157     + # set lock.. if not, exit
158     + unless (SetLock()) {
159     + die "Error: failed to create lock file.. is a backup already running?";
160     + }
161    
162     open(OLDSTDOUT, ">&STDOUT");
163     unless (open(STDOUT, ">$device/smeserver.tgz"))
164     @@ -118,6 +146,7 @@
165     open(STDERR, ">&OLDSTDERR");
166     close(OLDSTDERR);
167     close(OLDSTDOUT);
168     + RemoveLock();
169     return $status ? gettext("Backup failed. Look at the log files for more details.") : gettext("Backup successfully created.");
170     };
171     }
172     @@ -230,6 +259,7 @@
173     $devices->destroy;
174    
175     system("/sbin/e-smith/signal-event", 'post-backup');
176     + RemoveLock();
177     $console->message_page
178     (
179     title => gettext('Backup complete'),
180 unnilennium 1.2 diff -Nur e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk
181     --- e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk 2013-02-13 16:21:37.000000000 +0100
182     +++ e-smith-backup-2.6.0/root/sbin/e-smith/do_backupwk 2017-04-12 13:54:15.000000000 +0200
183     @@ -21,14 +21,27 @@
184     use strict;
185     use esmith::ConfigDB;
186     use esmith::BackupHistoryDB;
187     +use esmith::Backup;
188     +#use esmith::lockfile;
189     +
190     +# lock file.. see bug 9127
191     +my $backup_lock;
192    
193     $ENV{PATH} = "/sbin/e-smith:/sbin:/bin:/usr/bin";
194    
195     my $conf = esmith::ConfigDB->open || die("Could not open config db\n");
196     +
197     +# set lock.. if not, exit
198     +unless (SetLock()) {
199     + die "Error: failed to create lock file.. is a backup already running?";
200     +}
201     +
202     my $backup = $conf->get('backupwk');
203     my $status = $backup->prop('status') || 'disabled';
204     my $program = $backup->prop('Program') || 'dar';
205    
206     +
207     +
208     unless ($status eq 'enabled')
209     {
210     print "Backup is disabled\n";
211     @@ -61,6 +74,8 @@
212     $now = time();
213     $backup_rec->set_prop('EndEpochTime', "$now");
214     $backup_rec->set_prop('Result', "$status");
215     +# remove lock
216     +RemoveLock();
217     exit 0;
218    
219     sub bad_exit
220     @@ -71,5 +86,26 @@
221     warn("Backup terminated: $phase failed - status: $status\n");
222     $backup_rec->set_prop('EndEpochTime', "$now");
223     $backup_rec->set_prop('Result', "$phase:$status");
224     + # remove lock
225     + RemoveLock();
226     return $status / 256;
227     }
228     +
229     +# subs to set and remove lock on backup
230     +
231     +sub SetLock
232     +{
233     + print "Setting backup lock file\n";
234     + $backup_lock = esmith::Backup::set_lock;
235     + return $backup_lock;
236     +}
237     +
238     +sub RemoveLock
239     +{
240     + if (defined($backup_lock))
241     + {
242     + print "Removing backup lock file\n";
243     + esmith::Backup::remove_lock($backup_lock);
244     + $backup_lock = undef;
245     + }
246     +}

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