snapsync 0.2.0 → 0.2.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/lib/snapsync/auto_sync.rb +1 -1
- data/lib/snapsync/btrfs.rb +16 -5
- data/lib/snapsync/cleanup.rb +4 -1
- data/lib/snapsync/cli.rb +2 -0
- data/lib/snapsync/local_sync.rb +1 -1
- data/lib/snapsync/local_target.rb +11 -8
- data/lib/snapsync/snapshot.rb +3 -1
- data/lib/snapsync/sync_all.rb +2 -2
- data/lib/snapsync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba428d67c91dbc087576e7127910fe46aec8304
|
4
|
+
data.tar.gz: d530b254f9cdd7ca46c9d8e2d43ce6c64133afac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41595ef065834ee02890fde9fbdd7b94fa8c3197ed3808435e5d7f769e1be62201b41201772ae4651ececbadfcb38b3ac3809dc8be2425944250fc9205d4bba
|
7
|
+
data.tar.gz: 33cabe605c668f31b3d05ae704284f22ed312a108ced80741903c407a7d15f6b4ac87af17486664b3c82d4e287b9b4dddb7fd4003bf6c08415dc2fa7a405d5ee
|
data/lib/snapsync/auto_sync.rb
CHANGED
data/lib/snapsync/btrfs.rb
CHANGED
@@ -19,15 +19,26 @@ module Snapsync
|
|
19
19
|
|
20
20
|
def self.popen(*args, mode: 'r', raise_on_error: true, **options)
|
21
21
|
err_r, err_w = IO.pipe
|
22
|
-
|
22
|
+
|
23
|
+
block_error, block_result = nil
|
24
|
+
IO.popen(['btrfs', *args, err: err_w, **options], mode) do |io|
|
23
25
|
err_w.close
|
24
|
-
|
26
|
+
begin
|
27
|
+
block_result = yield(io)
|
28
|
+
rescue Error
|
29
|
+
raise
|
30
|
+
rescue Exception => block_error
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
|
-
if $?.success?
|
28
|
-
|
34
|
+
if $?.success? && !block_error
|
35
|
+
block_result
|
29
36
|
elsif raise_on_error
|
30
|
-
|
37
|
+
if block_error
|
38
|
+
raise Error.new, block_error.message
|
39
|
+
else
|
40
|
+
raise Error.new, "btrfs failed"
|
41
|
+
end
|
31
42
|
end
|
32
43
|
|
33
44
|
rescue Error => e
|
data/lib/snapsync/cleanup.rb
CHANGED
@@ -36,7 +36,10 @@ module Snapsync
|
|
36
36
|
if !deleted_snapshots.empty?
|
37
37
|
Snapsync.info "Waiting for subvolumes to be deleted"
|
38
38
|
deleted_snapshots.each do |s|
|
39
|
-
|
39
|
+
begin
|
40
|
+
Btrfs.popen("subvolume", "sync", s.subvolume_dir.to_s)
|
41
|
+
rescue Btrfs::Error
|
42
|
+
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
data/lib/snapsync/cli.rb
CHANGED
@@ -231,7 +231,9 @@ While it can easily be done manually, this command makes sure that the snapshots
|
|
231
231
|
desc 'list [DIR]', 'list the snapshots present on DIR. If DIR is omitted, tries to access all targets defined as auto-sync targets'
|
232
232
|
def list(dir = nil)
|
233
233
|
handle_class_options
|
234
|
+
matched_uuids = Set.new
|
234
235
|
each_target(dir) do |_, target|
|
236
|
+
matched_uuids << target.uuid
|
235
237
|
puts "== #{target.dir}"
|
236
238
|
puts "UUID: #{target.uuid}"
|
237
239
|
puts "Enabled: #{target.enabled?}"
|
data/lib/snapsync/local_sync.rb
CHANGED
@@ -84,7 +84,7 @@ module Snapsync
|
|
84
84
|
|
85
85
|
if copy_snapshot(target_snapshot_dir, src, parent: parent)
|
86
86
|
partial_marker_path.unlink
|
87
|
-
|
87
|
+
Btrfs.popen("filesystem", "sync", target_snapshot_dir.to_s)
|
88
88
|
Snapsync.info "Successfully synchronized #{src.snapshot_dir}"
|
89
89
|
true
|
90
90
|
end
|
@@ -136,15 +136,18 @@ module Snapsync
|
|
136
136
|
Snapsync.info "Removing snapshot #{s.num} #{s.date.to_time} at #{s.subvolume_dir}"
|
137
137
|
return if dry_run
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
if $?.success?
|
143
|
-
s.snapshot_dir.rmtree
|
144
|
-
Snapsync.info "Flushing data to disk"
|
145
|
-
IO.popen(["btrfs", "filesystem", "sync", s.snapshot_dir.to_s, err: '/dev/null']).read
|
146
|
-
else
|
139
|
+
begin
|
140
|
+
Btrfs.popen("subvolume", "delete", s.subvolume_dir.to_s)
|
141
|
+
rescue Btrfs::Error
|
147
142
|
Snapsync.warn "failed to remove snapshot at #{s.subvolume_dir}, keeping the rest of the snapshot"
|
143
|
+
return
|
144
|
+
end
|
145
|
+
|
146
|
+
s.snapshot_dir.rmtree
|
147
|
+
Snapsync.info "Flushing data to disk"
|
148
|
+
begin
|
149
|
+
Btrfs.popen("subvolume", "sync", s.subvolume_dir.to_s)
|
150
|
+
rescue Btrfs::Error
|
148
151
|
end
|
149
152
|
end
|
150
153
|
end
|
data/lib/snapsync/snapshot.rb
CHANGED
@@ -134,7 +134,9 @@ module Snapsync
|
|
134
134
|
end
|
135
135
|
|
136
136
|
xml = REXML::Document.new(info_xml.read)
|
137
|
-
if xml.root
|
137
|
+
if !xml.root
|
138
|
+
raise InvalidInfoFile, "#{snapshot_dir}/info.xml does not look like a snapper info file (not an XML file ?)"
|
139
|
+
elsif xml.root.name != 'snapshot'
|
138
140
|
raise InvalidInfoFile, "#{snapshot_dir}/info.xml does not look like a snapper info file (root is not 'snapshot')"
|
139
141
|
end
|
140
142
|
|
data/lib/snapsync/sync_all.rb
CHANGED
@@ -56,10 +56,10 @@ module Snapsync
|
|
56
56
|
rescue Interrupt
|
57
57
|
raise
|
58
58
|
rescue Exception => e
|
59
|
-
Snapsync.warn "failed to
|
59
|
+
Snapsync.warn "failed to synchronize #{config.name} on #{target.dir}"
|
60
60
|
PP.pp(e, buffer = String.new)
|
61
61
|
buffer.each_line do |line|
|
62
|
-
Snapsync.warn " #{line}"
|
62
|
+
Snapsync.warn " #{line.chomp}"
|
63
63
|
end
|
64
64
|
e.backtrace.each do |line|
|
65
65
|
Snapsync.debug " #{line}"
|
data/lib/snapsync/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Joyeux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|