lsync 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/{lsync-mount → lsync-disk} +0 -0
- data/bin/lsync-prune +1 -1
- data/lib/lsync.rb +12 -3
- data/lib/lsync/error.rb +4 -0
- data/lib/lsync/script.rb +5 -1
- data/lib/lsync/version.rb +1 -1
- metadata +22 -8
File without changes
|
data/bin/lsync-prune
CHANGED
@@ -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)
|
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
|
data/lib/lsync.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/lsync/error.rb
CHANGED
@@ -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
|
data/lib/lsync/script.rb
CHANGED
@@ -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
|
data/lib/lsync/version.rb
CHANGED
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
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:
|
28
|
+
hash: 23
|
29
29
|
segments:
|
30
30
|
- 1
|
31
31
|
- 2
|
32
|
-
-
|
33
|
-
version: 1.2.
|
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-
|
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-
|
77
|
+
- bin/lsync-disk
|
64
78
|
- bin/lsync-prune
|
65
79
|
- bin/lsync-rotate
|
66
80
|
- lib/lsync/client.rb
|