rsyncbackup 2.0.5 → 2.1.1
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.
- checksums.yaml +4 -4
- data/bin/rsyncbackup +1 -8
- data/lib/rsyncbackup.rb +4 -7
- data/lib/rsyncbackup/utilities.rb +25 -1
- data/lib/rsyncbackup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 461b1bf53f729f56cee8d7c4fc1139b7cdd5c933
|
4
|
+
data.tar.gz: 1a87c1837c47b8059c9b4433f819f35db78bc0bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ecae151fd9c7b238ed18326dad926164955ec8939b79712d1d46ff12c6ec3a3306b354e035adfa4f9bbc436b2d627b4c046c98910b89ed8c73a14454cb86817
|
7
|
+
data.tar.gz: a3fbdf1a992ff78fc7f82e7d6645a74d4d9c62023959cc647eeea05e697d2fe040bb07c687cd529b265d02afa50f2049c780ecf9df6bda8b87b9b9a904340ee9
|
data/bin/rsyncbackup
CHANGED
@@ -14,18 +14,11 @@ class App
|
|
14
14
|
begin
|
15
15
|
syncer = Rsyncbackup.new(source, target, options)
|
16
16
|
syncer.run
|
17
|
-
syncer.finalize
|
18
|
-
if syncer.status.success?
|
19
|
-
info syncer.output
|
20
|
-
else
|
21
|
-
error syncer.error
|
22
|
-
end
|
23
17
|
rescue Exception => e
|
24
18
|
error "Error occured in rsyncbackup: #{e.class} #{e}"
|
25
|
-
debug "Backtrace:\n#{e.backtrace}"
|
19
|
+
debug "Backtrace:\n#{e.backtrace.join("\n")}"
|
26
20
|
exit 127
|
27
21
|
end
|
28
|
-
syncer.status.exitstatus
|
29
22
|
end
|
30
23
|
|
31
24
|
description "Yet another rsync backup script, this time in ruby"
|
data/lib/rsyncbackup.rb
CHANGED
@@ -55,16 +55,13 @@ class Rsyncbackup
|
|
55
55
|
|
56
56
|
# the dry run option will be passed through to the rsync command,
|
57
57
|
# so we still do want to run it.
|
58
|
-
self.
|
59
|
-
debug "#{caller(0,1).first} self.
|
60
|
-
raise "Rsync Error: exit status: #{self.status.
|
58
|
+
self.status = _run_the_command(@cmd)
|
59
|
+
debug "#{caller(0,1).first} self.status #{self.status.inspect}"
|
60
|
+
raise "Rsync Error: exit status: #{self.status.exitstatus}" unless (self.status.success? || self.status.exitstatus == 23) # don't abort if some files could not be transferred
|
61
|
+
finalize
|
61
62
|
self
|
62
63
|
end
|
63
64
|
|
64
|
-
def success?
|
65
|
-
(@status.nil?) ? nil : @status.success?
|
66
|
-
end
|
67
|
-
|
68
65
|
def finalize
|
69
66
|
File.rename(@incomplete, @complete) if File.exist?(@incomplete)
|
70
67
|
File.write(File.join(@target,DEFAULT_LAST_FULL_DIR_NAME), backup_dir_name)
|
@@ -12,7 +12,31 @@
|
|
12
12
|
require 'methadone'
|
13
13
|
|
14
14
|
class Rsyncbackup
|
15
|
-
|
15
|
+
|
16
|
+
def _run_the_command(cmd)
|
17
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, t|
|
18
|
+
pid = t.pid
|
19
|
+
stdin.close
|
20
|
+
err_thr = Thread.new { copy_lines(stderr, $stderr) }
|
21
|
+
puts "Reading STDOUT"
|
22
|
+
copy_lines(stdout, $stdout)
|
23
|
+
err_thr.join
|
24
|
+
t.value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_lines(str_in, str_out)
|
29
|
+
str_in.each_line {|line| str_out.puts line}
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
# returns true if the rsync command was successful
|
35
|
+
def success?
|
36
|
+
(@status.nil?) ? nil : @status.success?
|
37
|
+
end
|
38
|
+
|
39
|
+
|
16
40
|
# returns the command string to execute with all parameters set
|
17
41
|
def build_command
|
18
42
|
|
data/lib/rsyncbackup/version.rb
CHANGED