rdiff_backup_wrapper 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25b38353dc6d7f53256849f97c83e0b7e4dcc886
|
4
|
+
data.tar.gz: 0c5cc4efd18ff17d7495ab612a139c8e52671e43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03bcada9964580d97789e4db28542c21d8128e8b9930f947255f95ac0e9324b181978e3c38cd85f3865356ec118e0a69937b731f12579f0cd03501929c2c5cd
|
7
|
+
data.tar.gz: ba67fb070572b54f3438df10ce1326c9eca76a20506f4816e9ca03bf3b30d937d7ac4e0df213e4b0985dd817f94585ce7be039996565f1982c07ff72549d8ad4
|
data/lib/rdiff_backup_wrapper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rdiff_backup_wrapper/version"
|
2
2
|
require "rdiff_backup_wrapper/backup"
|
3
|
+
require "rdiff_backup_wrapper/luks_loop_volume"
|
3
4
|
require 'yaml'
|
4
5
|
|
5
6
|
module RdiffBackupWrapper
|
@@ -21,20 +22,52 @@ module RdiffBackupWrapper
|
|
21
22
|
return @backups
|
22
23
|
end
|
23
24
|
@backups = []
|
24
|
-
config.each do |backup_config|
|
25
|
+
config['backups'].each do |backup_config|
|
25
26
|
@backups << Backup.new(backup_config)
|
26
27
|
end
|
27
28
|
@backups
|
28
29
|
end
|
29
30
|
|
31
|
+
def volumes
|
32
|
+
unless @volumes.nil?
|
33
|
+
return @volumes
|
34
|
+
end
|
35
|
+
@volumes = []
|
36
|
+
config['volumes'].each do |volume_config|
|
37
|
+
@volumes << Volume.create(volume_config)
|
38
|
+
end
|
39
|
+
@volumes
|
40
|
+
end
|
41
|
+
|
42
|
+
def prepare_volumes
|
43
|
+
volumes.each do |v|
|
44
|
+
v.prepare
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def cleanup_volumes
|
49
|
+
volumes.each do |v|
|
50
|
+
v.cleanup
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
30
54
|
def run
|
55
|
+
at_exit do
|
56
|
+
cleanup_volumes
|
57
|
+
end
|
58
|
+
prepare_volumes
|
59
|
+
ret_val = run_backups
|
60
|
+
exit ret_val
|
61
|
+
end
|
62
|
+
|
63
|
+
def run_backups
|
64
|
+
retval = 0
|
65
|
+
|
31
66
|
outputs = []
|
32
67
|
backups.each do |backup|
|
33
68
|
outputs << backup.run
|
34
69
|
end
|
35
70
|
|
36
|
-
retval = 0
|
37
|
-
|
38
71
|
outputs.each do |o|
|
39
72
|
if o[:retval].exitstatus != 0
|
40
73
|
retval = 1
|
@@ -47,7 +80,8 @@ module RdiffBackupWrapper
|
|
47
80
|
end
|
48
81
|
end
|
49
82
|
end
|
50
|
-
|
83
|
+
|
84
|
+
return retval
|
51
85
|
end
|
52
86
|
end
|
53
87
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
require 'open3'
|
3
|
+
require 'rdiff_backup_wrapper/volume'
|
4
|
+
|
5
|
+
module RdiffBackupWrapper
|
6
|
+
class LuksLoopVolume < Volume
|
7
|
+
def prepare_luks
|
8
|
+
Open3.popen3("cryptsetup", "luksOpen", luks_source, luks_name) do |i, o, e ,t|
|
9
|
+
i.puts "#{config['luksKey']}\n"
|
10
|
+
i.close
|
11
|
+
check_error(o, e, t)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def cleanup_luks
|
16
|
+
Open3.popen3("cryptsetup", "luksClose", luks_name) do |i, o, e ,t|
|
17
|
+
check_error(o, e, t)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def luks_name
|
22
|
+
config['name']
|
23
|
+
end
|
24
|
+
|
25
|
+
def luks_source
|
26
|
+
config['imagePath']
|
27
|
+
end
|
28
|
+
|
29
|
+
def luks_path
|
30
|
+
File.join('/dev/mapper', luks_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def luks_exists?
|
34
|
+
File.exists? luks_path
|
35
|
+
end
|
36
|
+
|
37
|
+
def mounted?
|
38
|
+
Open3.popen3("mountpoint", "-q", config['mountPoint']) do |i, o, e ,t|
|
39
|
+
if t.value.exitstatus == 0
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare_mount
|
47
|
+
Open3.popen3("mount", luks_path, config['mountPoint']) do |i, o, e ,t|
|
48
|
+
check_error(o, e, t)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def cleanup_mount
|
53
|
+
Open3.popen3("umount", config['mountPoint']) do |i, o, e ,t|
|
54
|
+
check_error(o, e, t)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def prepare
|
59
|
+
prepare_luks
|
60
|
+
prepare_mount
|
61
|
+
end
|
62
|
+
|
63
|
+
def cleanup
|
64
|
+
if mounted?
|
65
|
+
cleanup_mount
|
66
|
+
end
|
67
|
+
if luks_exists?
|
68
|
+
cleanup_luks
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rdiff_backup_wrapper/luks_loop_volume'
|
2
|
+
|
3
|
+
module RdiffBackupWrapper
|
4
|
+
class Volume
|
5
|
+
def self.create(config)
|
6
|
+
if config['type'] == 'luks-loop'
|
7
|
+
LuksLoopVolume.new config
|
8
|
+
else
|
9
|
+
raise "Unknown volume type '#{config['type']}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
def initialize(config)
|
16
|
+
@config = config
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_error(o, e, t)
|
20
|
+
return if t.value.exitstatus == 0
|
21
|
+
STDERR.puts e.read
|
22
|
+
STDERR.puts o.read
|
23
|
+
STDERR.puts t
|
24
|
+
raise "error"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdiff_backup_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Simon
|
@@ -71,7 +71,9 @@ files:
|
|
71
71
|
- bin/rdiff-backup-wrapper
|
72
72
|
- lib/rdiff_backup_wrapper.rb
|
73
73
|
- lib/rdiff_backup_wrapper/backup.rb
|
74
|
+
- lib/rdiff_backup_wrapper/luks_loop_volume.rb
|
74
75
|
- lib/rdiff_backup_wrapper/version.rb
|
76
|
+
- lib/rdiff_backup_wrapper/volume.rb
|
75
77
|
- rdiff_backup_wrapper.gemspec
|
76
78
|
homepage: https://github.com/simonswine/rdiff_backup_wrapper
|
77
79
|
licenses:
|