zfs_mgmt 0.4.3 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +22 -19
- data/bin/zfsmgr +1 -1
- data/lib/zfs_mgmt/restic.rb +1 -1
- data/lib/zfs_mgmt/version.rb +1 -1
- data/lib/zfs_mgmt/zfs_mgr/send.rb +3 -26
- data/lib/zfs_mgmt.rb +53 -23
- data/zfs_mgmt.gemspec +4 -4
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1022834076fa1482f627f9c5b7f8a476dd3e83d3358495d40f6695b23e842a88
|
4
|
+
data.tar.gz: ddc4f5f6e87c00f5cb0c0adbe2b4ddc47f78670c520b701d359b471b19c081c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06eab68af755becb316e438c5e027e78166952c7a37dc1c32343193f140e0a12463784b6a42ada068c0a90571641a11c7971143349d0dff6cc1a2581f34cbe9b
|
7
|
+
data.tar.gz: 9fa676ecf9837096a5e97649f01dfa398610898019f4abd0694fee241e75733767193898e26e618516c23cbf394dcdf1bdb8d9c4639a70a77d49db5b34c2ede4
|
data/Gemfile.lock
CHANGED
@@ -1,36 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zfs_mgmt (0.4.
|
4
|
+
zfs_mgmt (0.4.6)
|
5
|
+
filesize (~> 0.2)
|
6
|
+
text-table (~> 1.2)
|
7
|
+
thor (~> 1.0)
|
5
8
|
|
6
9
|
GEM
|
7
10
|
remote: https://rubygems.org/
|
8
11
|
specs:
|
9
|
-
diff-lcs (1.
|
12
|
+
diff-lcs (1.5.0)
|
10
13
|
filesize (0.2.0)
|
11
|
-
json (2.
|
12
|
-
rake (13.0.
|
13
|
-
rspec (3.
|
14
|
-
rspec-core (~> 3.
|
15
|
-
rspec-expectations (~> 3.
|
16
|
-
rspec-mocks (~> 3.
|
17
|
-
rspec-core (3.
|
18
|
-
rspec-support (~> 3.
|
19
|
-
rspec-expectations (3.
|
14
|
+
json (2.6.2)
|
15
|
+
rake (13.0.6)
|
16
|
+
rspec (3.11.0)
|
17
|
+
rspec-core (~> 3.11.0)
|
18
|
+
rspec-expectations (~> 3.11.0)
|
19
|
+
rspec-mocks (~> 3.11.0)
|
20
|
+
rspec-core (3.11.0)
|
21
|
+
rspec-support (~> 3.11.0)
|
22
|
+
rspec-expectations (3.11.0)
|
20
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.
|
22
|
-
rspec-mocks (3.
|
24
|
+
rspec-support (~> 3.11.0)
|
25
|
+
rspec-mocks (3.11.1)
|
23
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.
|
25
|
-
rspec-support (3.
|
27
|
+
rspec-support (~> 3.11.0)
|
28
|
+
rspec-support (3.11.0)
|
26
29
|
text-table (1.2.4)
|
27
|
-
thor (1.
|
30
|
+
thor (1.2.1)
|
28
31
|
|
29
32
|
PLATFORMS
|
30
|
-
|
33
|
+
x86_64-linux
|
31
34
|
|
32
35
|
DEPENDENCIES
|
33
|
-
bundler (
|
36
|
+
bundler (>= 2.2.33)
|
34
37
|
filesize
|
35
38
|
json
|
36
39
|
rake (>= 12.3.3)
|
@@ -40,4 +43,4 @@ DEPENDENCIES
|
|
40
43
|
zfs_mgmt!
|
41
44
|
|
42
45
|
BUNDLED WITH
|
43
|
-
|
46
|
+
2.3.21
|
data/bin/zfsmgr
CHANGED
@@ -17,7 +17,7 @@ class ZfsMgr < Thor
|
|
17
17
|
:enum => ['debug','error','fatal','info','warn'],
|
18
18
|
:desc => 'set logging level to specified severity'
|
19
19
|
desc "zfsget [ZFS]", "execute zfs get for the given properties and types and parse the output into a nested hash"
|
20
|
-
method_option :properties, :type => :
|
20
|
+
method_option :properties, :type => :string, :default => ['name'], :desc => "List of properties passed to zfs get", repeatable: true
|
21
21
|
method_option :types, :type => :array, :default => ['filesystem','volume'], enum: ['filesystem','volume','snapshot'], :desc => "list of types"
|
22
22
|
def zfsget(zfs)
|
23
23
|
ZfsMgmt.set_log_level(options[:loglevel])
|
data/lib/zfs_mgmt/restic.rb
CHANGED
@@ -70,7 +70,7 @@ module ZfsMgmt::Restic
|
|
70
70
|
'zfsmgmt:restic_repository',
|
71
71
|
'userrefs',
|
72
72
|
],
|
73
|
-
property_match: { 'zfsmgmt:restic_backup' => 'true' }).each do |blob|
|
73
|
+
property_match: { 'zfsmgmt:restic_backup' => ['on','true'] }).each do |blob|
|
74
74
|
zfs,props,zfs_snapshots = blob
|
75
75
|
last_zfs_snapshot = zfs_snapshots.keys.sort { |a,b| zfs_snapshots[a]['creation'] <=> zfs_snapshots[b]['creation'] }.last
|
76
76
|
zfs_snap_time = Time.at(zfs_snapshots[last_zfs_snapshot]['creation'])
|
data/lib/zfs_mgmt/version.rb
CHANGED
@@ -25,8 +25,8 @@ class ZfsMgmt::ZfsMgr::Send < Thor
|
|
25
25
|
|
26
26
|
method_option :noop, :aliases => :'-n', :desc => "pass -n (noop) option to zfs send", :type => :boolean
|
27
27
|
method_option :unmount, :aliases => :'-u', :desc => "pass -u (unmount) option to zfs receive", :type => :boolean
|
28
|
-
method_option :exclude, :aliases => :'-x', :desc => "passed to -x option of receive side", :type => :
|
29
|
-
method_option :option, :aliases => :'-o', :desc => "passed to -o option of receive side", :type => :
|
28
|
+
method_option :exclude, :aliases => :'-x', :desc => "passed to -x option of receive side", :type => :string, repeatable: true
|
29
|
+
method_option :option, :aliases => :'-o', :desc => "passed to -o option of receive side", :type => :string, repeatable: true
|
30
30
|
method_option :drop_holds, :desc => "pass the -h option to zfs recv, indicating holds should be ignored", :type => :boolean
|
31
31
|
|
32
32
|
method_option :mbuffer, :desc => "insert mbuffer between send and recv", :default => true, :type => :boolean
|
@@ -35,29 +35,6 @@ class ZfsMgmt::ZfsMgr::Send < Thor
|
|
35
35
|
ZfsMgmt.set_log_level(options[:loglevel])
|
36
36
|
ZfsMgmt.global_options = options
|
37
37
|
|
38
|
-
|
39
|
-
{ 'zfsmgmt:send' => 'true' },
|
40
|
-
# {
|
41
|
-
# 'zfsmgmt:send' => 'replicate',
|
42
|
-
# 'zfsmgmt:send@source' => 'local'
|
43
|
-
# },
|
44
|
-
].each do |match|
|
45
|
-
ZfsMgmt.zfs_managed_list(filter: options[:filter],
|
46
|
-
property_match: match).each do |zfs,props,snaps|
|
47
|
-
if props['zfsmgmt:send@source'] == 'received'
|
48
|
-
$logger.debug("skipping received filesystem: #{zfs}")
|
49
|
-
next
|
50
|
-
end
|
51
|
-
if props.has_key?('zfsmgmt:send_replicate') and props['zfsmgmt:send_replicate'] == 'true' and props['zfsmgmt:send_replicate@source'] != 'local'
|
52
|
-
$logger.debug("skipping descendant of replicated filesystems: #{zfs}")
|
53
|
-
next
|
54
|
-
end
|
55
|
-
unless props['zfsmgmt:destination']
|
56
|
-
$logger.error("#{zfs}: you must specify a destination zfs path via the user property zfsmgmt:destination, even if using --destination on the command line, skipping")
|
57
|
-
next
|
58
|
-
end
|
59
|
-
ZfsMgmt.zfs_send(options,zfs,props,snaps)
|
60
|
-
end
|
61
|
-
end
|
38
|
+
ZfsMgmt.zfs_send_all(options)
|
62
39
|
end
|
63
40
|
end
|
data/lib/zfs_mgmt.rb
CHANGED
@@ -238,7 +238,7 @@ module ZfsMgmt
|
|
238
238
|
}
|
239
239
|
return saved,saved_snaps,deleteme
|
240
240
|
end
|
241
|
-
def self.zfs_managed_list(filter: '.+', properties: ['all'], property_match: { 'zfsmgmt:manage' =>
|
241
|
+
def self.zfs_managed_list(filter: '.+', properties: ['all'], property_match: { 'zfsmgmt:manage' => method(:prop_on?) } )
|
242
242
|
zfss = [] # array of arrays
|
243
243
|
zfsget(properties: properties).each do |zfs,props|
|
244
244
|
unless /#{filter}/ =~ zfs
|
@@ -246,7 +246,7 @@ module ZfsMgmt
|
|
246
246
|
end
|
247
247
|
managed = true
|
248
248
|
property_match.each do |k,v|
|
249
|
-
unless
|
249
|
+
unless key_comp?(props,k,v)
|
250
250
|
managed = false
|
251
251
|
break
|
252
252
|
end
|
@@ -311,7 +311,7 @@ module ZfsMgmt
|
|
311
311
|
$logger.debug("delete: #{snap_name} #{local_epoch_to_datetime(snaps[snap_name]['creation']).strftime('%F %T')}")
|
312
312
|
end
|
313
313
|
|
314
|
-
com_base = [
|
314
|
+
com_base = [ZfsMgmt.global_options[:zfs_binary], 'destroy']
|
315
315
|
com_base.push('-d') if deleteme.length > 0 # why?
|
316
316
|
com_base.push('-n') if noop
|
317
317
|
com_base.push('-v') if verbose
|
@@ -422,8 +422,8 @@ module ZfsMgmt
|
|
422
422
|
com = []
|
423
423
|
source = sorted[0]
|
424
424
|
if options[:initial_snapshot] == 'newest' or
|
425
|
-
(
|
426
|
-
(
|
425
|
+
key_comp?(options, 'replicate') or
|
426
|
+
key_comp?(props, 'zfsmgmt:send_replicate')
|
427
427
|
source = sorted[-1]
|
428
428
|
end
|
429
429
|
com += zfs_send_com(options,
|
@@ -445,7 +445,7 @@ module ZfsMgmt
|
|
445
445
|
# should be resumable!
|
446
446
|
com = [ ]
|
447
447
|
com.push( ZfsMgmt.global_options[:zfs_binary], 'send', '-t', remote_zfs_state )
|
448
|
-
com.push('-v','-P') if options
|
448
|
+
com.push('-v','-P') if key_comp?(options, 'verbose', 'send')
|
449
449
|
com.push('|')
|
450
450
|
e = zfs_send_estimate(com) if options[:verbose] == 'pv'
|
451
451
|
com += mbuffer_command(options) if options[:mbuffer]
|
@@ -498,7 +498,15 @@ module ZfsMgmt
|
|
498
498
|
if snaps.has_key?(rsnap.sub(destination_path,zfs))
|
499
499
|
$logger.debug("process #{rsnap} to #{sorted[-1]}")
|
500
500
|
com = []
|
501
|
-
|
501
|
+
i_opt = '-i'
|
502
|
+
# allow the command line option for intermediary to override the property
|
503
|
+
if key_comp?(options,'intermediary',[true,false])
|
504
|
+
i_opt = '-I' if key_comp?(options, 'intermediary', true)
|
505
|
+
elsif key_comp?(props, 'zfsmgmt:send_intermediary')
|
506
|
+
i_opt = '-I'
|
507
|
+
end
|
508
|
+
|
509
|
+
com += zfs_send_com(options,props,[i_opt, dq('@' + rsnap.split('@')[1])], sorted[-1])
|
502
510
|
e = zfs_send_estimate(com) if options[:verbose] == 'pv'
|
503
511
|
com += mbuffer_command(options) if options[:mbuffer]
|
504
512
|
com += pv_command(options,e) if options[:verbose] == 'pv'
|
@@ -521,7 +529,7 @@ module ZfsMgmt
|
|
521
529
|
end
|
522
530
|
def self.zfs_send_com(options,props,extra_opts,target)
|
523
531
|
zfs_send_com = [ ZfsMgmt.global_options[:zfs_binary], 'send' ]
|
524
|
-
zfs_send_com.push('-v','-P') if options
|
532
|
+
zfs_send_com.push('-v','-P') if key_comp?(options,'verbose','send')
|
525
533
|
send_opts = {
|
526
534
|
'backup' => '-b',
|
527
535
|
'compressed' => '-c',
|
@@ -533,10 +541,11 @@ module ZfsMgmt
|
|
533
541
|
'replicate' => '-R',
|
534
542
|
}
|
535
543
|
send_opts.each do |p,o|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
544
|
+
# allow the command line options to override the properties value
|
545
|
+
if key_comp?(options,p,[true,false])
|
546
|
+
zfs_send_com.push(o) if key_comp?(options,p,true)
|
547
|
+
elsif key_comp?(props,"zfsmgmt:send_#{p}")
|
548
|
+
zfs_send_com.push(o)
|
540
549
|
end
|
541
550
|
end
|
542
551
|
zfs_send_com + extra_opts + [dq(target),'|']
|
@@ -544,18 +553,21 @@ module ZfsMgmt
|
|
544
553
|
def self.zfs_recv_com(options,extra_opts,props,target)
|
545
554
|
zfs_recv_com = [ ZfsMgmt.global_options[:zfs_binary], 'recv', '-F', '-s' ]
|
546
555
|
recv_opts = {
|
547
|
-
'noop'
|
548
|
-
'drop_holds'
|
549
|
-
'unmount'
|
556
|
+
'noop' => '-n',
|
557
|
+
'drop_holds' => '-h',
|
558
|
+
'unmount' => '-u',
|
559
|
+
#'discard_last' => '-e',
|
560
|
+
#'discard_first' => '-d',
|
550
561
|
}
|
551
562
|
recv_opts.each do |p,o|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
563
|
+
# allow the command line options to override the properties value
|
564
|
+
if key_comp?(options,p,[true,false])
|
565
|
+
zfs_recv_com.push(o) if key_comp?(options,p,true)
|
566
|
+
elsif key_comp?(props,"zfsmgmt:recv_#{p}")
|
567
|
+
zfs_recv_com.push(o)
|
556
568
|
end
|
557
569
|
end
|
558
|
-
zfs_recv_com.push('-v') if options
|
570
|
+
zfs_recv_com.push('-v') if key_comp?(options, 'verbose', ['receive', 'recv'])
|
559
571
|
if options[:exclude]
|
560
572
|
options[:exclude].each do |x|
|
561
573
|
zfs_recv_com.push('-x',x)
|
@@ -628,14 +640,13 @@ module ZfsMgmt
|
|
628
640
|
return v.include?(h[p])
|
629
641
|
elsif v.kind_of?(Hash)
|
630
642
|
return v.keys.include?(h[p])
|
631
|
-
elsif v.kind_of?(String)
|
632
|
-
return h[p] == v
|
633
643
|
elsif v.kind_of?(Method)
|
634
644
|
return v.call(h[p])
|
635
645
|
elsif v.kind_of?(Regexp)
|
636
646
|
return v =~ h[p]
|
637
647
|
else
|
638
|
-
|
648
|
+
# string, boolean, numbers?
|
649
|
+
return h[p] == v
|
639
650
|
end
|
640
651
|
end
|
641
652
|
def self.set_log_level(sev)
|
@@ -652,4 +663,23 @@ module ZfsMgmt
|
|
652
663
|
$logger.level = Logger::FATAL
|
653
664
|
end
|
654
665
|
end
|
666
|
+
def self.zfs_send_all(options)
|
667
|
+
zfs_managed_list(filter: options[:filter],
|
668
|
+
property_match: { 'zfsmgmt:send' => method(:prop_on?) }).each do |zfs,props,snaps|
|
669
|
+
|
670
|
+
if props['zfsmgmt:send@source'] == 'received'
|
671
|
+
$logger.debug("skipping received filesystem: #{zfs}")
|
672
|
+
next
|
673
|
+
end
|
674
|
+
if key_comp?(props,'zfsmgmt:send_replicate') and props['zfsmgmt:send_replicate@source'] != 'local'
|
675
|
+
$logger.debug("skipping descendant of replicated filesystems: #{zfs}")
|
676
|
+
next
|
677
|
+
end
|
678
|
+
unless props['zfsmgmt:destination']
|
679
|
+
$logger.error("#{zfs}: you must specify a destination zfs path via the user property zfsmgmt:destination, even if using --destination on the command line, skipping")
|
680
|
+
next
|
681
|
+
end
|
682
|
+
zfs_send(options,zfs,props,snaps)
|
683
|
+
end
|
684
|
+
end
|
655
685
|
end
|
data/zfs_mgmt.gemspec
CHANGED
@@ -36,11 +36,11 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.executables = ['readsnaps','zfssendman','zfssnapman','zfsrecvman','zfs-list-snapshots','zfsmgr']
|
37
37
|
spec.require_paths = ["lib"]
|
38
38
|
|
39
|
-
spec.add_development_dependency "bundler", "
|
39
|
+
spec.add_development_dependency "bundler", ">= 2.2.33"
|
40
40
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
41
41
|
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
-
spec.
|
43
|
-
spec.
|
44
|
-
spec.
|
42
|
+
spec.add_runtime_dependency "thor", "~> 1.0"
|
43
|
+
spec.add_runtime_dependency "text-table", "~> 1.2"
|
44
|
+
spec.add_runtime_dependency "filesize", "~> 0.2"
|
45
45
|
|
46
46
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfs_mgmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aran Cox
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.33
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.33
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.0'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.2'
|
76
|
-
type: :
|
76
|
+
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.2'
|
90
|
-
type: :
|
90
|
+
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.2'
|
97
|
-
description:
|
97
|
+
description:
|
98
98
|
email:
|
99
99
|
- arancox@gmail.com
|
100
100
|
executables:
|
@@ -140,7 +140,7 @@ metadata:
|
|
140
140
|
homepage_uri: https://github.com/aranc23/zfs_mgmt
|
141
141
|
source_code_uri: https://github.com/aranc23/zfs_mgmt
|
142
142
|
changelog_uri: https://github.com/aranc23/zfs_mgmt/commits/
|
143
|
-
post_install_message:
|
143
|
+
post_install_message:
|
144
144
|
rdoc_options: []
|
145
145
|
require_paths:
|
146
146
|
- lib
|
@@ -155,8 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
- !ruby/object:Gem::Version
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
159
|
-
signing_key:
|
158
|
+
rubygems_version: 3.3.7
|
159
|
+
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: Misc. helpers regarding snapshots and send/recv.
|
162
162
|
test_files: []
|