lsync 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -248,7 +248,7 @@ ARGV.options do |o|
248
248
  o.separator ""
249
249
 
250
250
  o.on_tail("--copy", "Display copyright information") do
251
- puts "#{script_name}. Copyright (c) 2008-2009 Samuel Williams. Released under the GPLv3."
251
+ puts "#{script_name}. Copyright (c) 2007-2011 Samuel Williams. Released under the MIT license."
252
252
  puts "See http://www.oriontransfer.co.nz/ for more information."
253
253
 
254
254
  exit
@@ -33,17 +33,26 @@ require 'fileutils'
33
33
  require 'optparse'
34
34
 
35
35
  require 'open-uri'
36
+ require 'lockfile'
36
37
 
37
38
  module LSync
38
-
39
+
40
+ # Run a prepared backup script using a lockfile.
39
41
  def self.run_script(options = {}, &block)
40
42
  script = LSync::Script.new(options, &block)
41
-
43
+ lockfile_path = $0 + ".lock"
44
+
42
45
  script.on(:failure) do |error|
43
46
  LSync::log_error(error, logger)
44
47
  end
45
48
 
46
- script.run!
49
+ begin
50
+ Lockfile.new(lockfile_path, :retries => 0) do
51
+ script.run!
52
+ end
53
+ rescue Lockfile::MaxTriesLockError
54
+ raise LockError.new("Lockfile #{lockfile_path} could not be acquired.")
55
+ end
47
56
  end
48
57
 
49
58
  end
@@ -39,6 +39,10 @@ module LSync
39
39
  class ScriptError < Error
40
40
  end
41
41
 
42
+ # Indicates that a backup could not be run because it was already locked.
43
+ class LockError < Error
44
+ end
45
+
42
46
  # Indicates that there has been a major backup method error.
43
47
  class BackupMethodError < Error
44
48
  end
@@ -147,10 +147,14 @@ module LSync
147
147
  # Log data (an +IO+) specific to the current script.
148
148
  attr :log
149
149
 
150
+ public
151
+
150
152
  # Run the backup process for all servers and directories specified.
151
153
  def run!(options = {})
152
154
  start_time = Time.now
153
155
 
156
+ logger.info "===== Starting backup at #{start_time} ====="
157
+
154
158
  # We buffer the log data so that if there is an error it is available to the notification sub-system
155
159
  @log = StringIO.new
156
160
  local_logger = Logger.new(@log)
@@ -178,8 +182,8 @@ module LSync
178
182
  end
179
183
 
180
184
  end_time = Time.now
181
- logger.info "===== Finished ====="
182
185
  logger.info "[Time]: (#{end_time - start_time}s)."
186
+ logger.info "===== Finished backup at #{end_time} ====="
183
187
  end
184
188
 
185
189
  protected
@@ -22,7 +22,7 @@ module LSync
22
22
  module VERSION
23
23
  MAJOR = 2
24
24
  MINOR = 3
25
- TINY = 2
25
+ TINY = 3
26
26
 
27
27
  STRING = [MAJOR, MINOR, TINY].join('.')
28
28
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 2
10
- version: 2.3.2
9
+ - 3
10
+ version: 2.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Samuel Williams
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 25
28
+ hash: 23
29
29
  segments:
30
30
  - 1
31
31
  - 2
32
- - 3
33
- version: 1.2.3
32
+ - 4
33
+ version: 1.2.4
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -49,10 +49,24 @@ dependencies:
49
49
  version: 1.4.1
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: lockfile
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
52
66
  description:
53
67
  email: samuel.williams@oriontransfer.co.nz
54
68
  executables:
55
- - lsync-mount
69
+ - lsync-disk
56
70
  - lsync-prune
57
71
  - lsync-rotate
58
72
  extensions: []
@@ -60,7 +74,7 @@ extensions: []
60
74
  extra_rdoc_files: []
61
75
 
62
76
  files:
63
- - bin/lsync-mount
77
+ - bin/lsync-disk
64
78
  - bin/lsync-prune
65
79
  - bin/lsync-rotate
66
80
  - lib/lsync/client.rb