zfs_mgmt 0.3.9 → 0.3.10
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/Gemfile.lock +1 -1
- data/bin/zfsmgr +5 -0
- data/lib/zfs_mgmt.rb +9 -5
- data/lib/zfs_mgmt/restic.rb +1 -1
- data/lib/zfs_mgmt/version.rb +1 -1
- data/lib/zfs_mgmt/zfs_mgr/list.rb +1 -0
- data/lib/zfs_mgmt/zfs_mgr/restic.rb +3 -2
- data/lib/zfs_mgmt/zfs_mgr/snapshot.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a54ed2e0ad255f69367aaeb25fd0dddcc8346cec0fd8be02561e4ea1210510f2
|
4
|
+
data.tar.gz: 1d31c311f63835c3f7a2b6e771b06628f1901b62130e9ec5d0255ff987fb89bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0534143034e6edb6ce1161bacd86765cf9a151812d1849f3570c983691dfdf8d03f5d0aeefb070fa144fa0fa6838711b855e07180a7c70cd14f3f00d561d562
|
7
|
+
data.tar.gz: dbf53bcfe6223106f080393621d58ef538a2cf9fe9ae9e7f338b2cbe4e5d88d5bca2fcf44f3c6e8ffb76050ce2d0cfc75fa12638b8d19aae759b9b507fab3a65
|
data/Gemfile.lock
CHANGED
data/bin/zfsmgr
CHANGED
@@ -5,10 +5,15 @@ require "zfs_mgmt/zfs_mgr"
|
|
5
5
|
require "zfs_mgmt/zfs_mgr/restic"
|
6
6
|
|
7
7
|
class ZfsMgr < Thor
|
8
|
+
class_option :zfs_binary, :type => :string, :default => 'zfs',
|
9
|
+
:desc => 'zfs binary'
|
10
|
+
class_option :zpool_binary, :type => :string, :default => 'zpool',
|
11
|
+
:desc => 'zfs binary'
|
8
12
|
desc "zfsget [ZFS]", "execute zfs get for the given properties and types and parse the output into a nested hash"
|
9
13
|
method_option :properties, :type => :array, :default => ['name'], :desc => "List of properties passed to zfs get"
|
10
14
|
method_option :types, :type => :array, :default => ['filesystem','volume'], enum: ['filesystem','volume','snapshot'], :desc => "list of types"
|
11
15
|
def zfsget(zfs)
|
16
|
+
ZfsMgmt.global_options = options
|
12
17
|
pp ZfsMgmt.zfsget(properties: options[:properties],
|
13
18
|
types: options[:types],
|
14
19
|
zfs: zfs)
|
data/lib/zfs_mgmt.rb
CHANGED
@@ -38,6 +38,9 @@ $properties_xlate = {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
module ZfsMgmt
|
41
|
+
class << self
|
42
|
+
attr_accessor :global_options
|
43
|
+
end
|
41
44
|
def self.custom_properties()
|
42
45
|
return [
|
43
46
|
'policy',
|
@@ -67,7 +70,7 @@ module ZfsMgmt
|
|
67
70
|
end
|
68
71
|
|
69
72
|
def self.zfs_holds(snapshot)
|
70
|
-
com = ['
|
73
|
+
com = [global_options['zfs_binary'], 'holds', '-H', snapshot]
|
71
74
|
$logger.debug("#{com.join(' ')}")
|
72
75
|
out = %x(#{com.join(' ')})
|
73
76
|
unless $?.success?
|
@@ -83,7 +86,7 @@ module ZfsMgmt
|
|
83
86
|
end
|
84
87
|
|
85
88
|
def self.zfs_hold(hold,snapshot)
|
86
|
-
com = ['
|
89
|
+
com = [global_options['zfs_binary'], 'hold', hold, snapshot]
|
87
90
|
$logger.debug("#{com.join(' ')}")
|
88
91
|
system(com.join(' '))
|
89
92
|
unless $?.success?
|
@@ -94,7 +97,7 @@ module ZfsMgmt
|
|
94
97
|
end
|
95
98
|
|
96
99
|
def self.zfs_release(hold,snapshot)
|
97
|
-
com = ['
|
100
|
+
com = [@global_options['zfs_binary'], 'release', hold, snapshot]
|
98
101
|
$logger.debug("#{com.join(' ')}")
|
99
102
|
system(com.join(' '))
|
100
103
|
unless $?.success?
|
@@ -106,7 +109,8 @@ module ZfsMgmt
|
|
106
109
|
|
107
110
|
def self.zfsget(properties: ['name'],types: ['filesystem','volume'],zfs: '')
|
108
111
|
results={}
|
109
|
-
com = [
|
112
|
+
com = [ZfsMgmt.global_options[:zfs_binary], 'get', '-Hp', properties.join(','), '-t', types.join(','), zfs]
|
113
|
+
$logger.debug(com.join(' '))
|
110
114
|
so,se,status = Open3.capture3(com.join(' '))
|
111
115
|
if status.signaled?
|
112
116
|
$logger.error("process was signalled \"#{com.join(' ')}\", termsig #{status.termsig}")
|
@@ -371,7 +375,7 @@ module ZfsMgmt
|
|
371
375
|
|
372
376
|
prefix = ( props.has_key?('zfsmgmt:snap_prefix') ? props['zfsmgmt:snap_prefix'] : 'zfsmgmt' )
|
373
377
|
ts = ( props.has_key?('zfsmgmt:snap_timestamp') ? props['zfsmgmt:snap_timestamp'] : '%FT%T%z' )
|
374
|
-
com = ['
|
378
|
+
com = [global_options['zfs_binary'],'snapshot']
|
375
379
|
if props['zfsmgmt:snapshot'] == 'recursive' and props['zfsmgmt:snapshot@source'] == 'local'
|
376
380
|
com.push('-r')
|
377
381
|
end
|
data/lib/zfs_mgmt/restic.rb
CHANGED
@@ -107,7 +107,7 @@ module ZfsMgmt::Restic
|
|
107
107
|
"zfsmgmt:snapshot=#{last_zfs_snapshot}",
|
108
108
|
"zfsmgmt:zfs=#{zfs}",
|
109
109
|
"zfsmgmt:level=#{level}" ]
|
110
|
-
com = [
|
110
|
+
com = [ ZfsMgmt.global_options['zfs_binary'], 'send', '-L', '-w', '-h', '-p' ]
|
111
111
|
if level > 0
|
112
112
|
if options[:intermediary]
|
113
113
|
com.push('-I')
|
data/lib/zfs_mgmt/version.rb
CHANGED
@@ -6,6 +6,7 @@ class ZfsMgmt::ZfsMgr::List < Thor
|
|
6
6
|
desc "stale", "list all zfs with stale snapshots"
|
7
7
|
method_option :age, :desc => "timeframe outside of which the zfs will be considered stale", :default => '1d'
|
8
8
|
def stale()
|
9
|
+
ZfsMgmt.global_options = options
|
9
10
|
cutoff = Time.at(Time.now.to_i - ZfsMgmt.timespec_to_seconds(options[:age]))
|
10
11
|
table = Text::Table.new
|
11
12
|
table.head = ['zfs','snapshot','age']
|
@@ -5,8 +5,6 @@ class ZfsMgmt::ZfsMgr::Backup < Thor
|
|
5
5
|
:desc => 'only act on zfs matching this regexp'
|
6
6
|
class_option :restic_binary, :type => :string, :default => 'restic',
|
7
7
|
:desc => 'restic binary'
|
8
|
-
class_option :zfs_binary, :type => :string, :default => 'zfs',
|
9
|
-
:desc => 'zfs binary'
|
10
8
|
class_option :verbose, :alias => '-v', :type => :numeric,
|
11
9
|
:desc => 'verbosity level for restic'
|
12
10
|
class_option :buffer, :type => :string, :default => '256m',
|
@@ -21,15 +19,18 @@ class ZfsMgmt::ZfsMgr::Backup < Thor
|
|
21
19
|
method_option :level, :desc => "backup level in integer form", :default => 2, :type => :numeric
|
22
20
|
method_option :intermediary, :alias => '-I', :desc => "pass -I (intermediary) option to zfs send", :default => false, :type => :boolean
|
23
21
|
def incremental()
|
22
|
+
ZfsMgmt.global_options = options
|
24
23
|
ZfsMgmt::Restic.backup(backup_level: options[:level], options: options)
|
25
24
|
end
|
26
25
|
desc "differential", "perform differential backup"
|
27
26
|
method_option :intermediary, :alias => '-I', :desc => "pass -I (intermediary) option to zfs send", :default => false, :type => :boolean
|
28
27
|
def differential()
|
28
|
+
ZfsMgmt.global_options = options
|
29
29
|
ZfsMgmt::Restic.backup(backup_level: 1, options: options)
|
30
30
|
end
|
31
31
|
desc "full", "perform full backup"
|
32
32
|
def full()
|
33
|
+
ZfsMgmt.global_options = options
|
33
34
|
ZfsMgmt::Restic.backup(backup_level: 0, options: options)
|
34
35
|
end
|
35
36
|
end
|
@@ -11,14 +11,17 @@ class ZfsMgmt::ZfsMgr::Snapshot < Thor
|
|
11
11
|
:desc => 'only act on zfs matching this regexp'
|
12
12
|
desc "destroy", "apply the snapshot destroy policy to zfs"
|
13
13
|
def destroy()
|
14
|
+
ZfsMgmt.global_options = options
|
14
15
|
ZfsMgmt.snapshot_destroy(noop: options[:noop], verbopt: options[:verbose], debugopt: options[:debug], filter: options[:filter])
|
15
16
|
end
|
16
17
|
desc "policy", "print the policy table for zfs"
|
17
18
|
def policy()
|
19
|
+
ZfsMgmt.global_options = options
|
18
20
|
ZfsMgmt.snapshot_policy(verbopt: options[:verbose], debugopt: options[:debug], filter: options[:filter])
|
19
21
|
end
|
20
22
|
desc "create", "execute zfs snapshot based on zfs properties"
|
21
23
|
def create()
|
24
|
+
ZfsMgmt.global_options = options
|
22
25
|
ZfsMgmt.snapshot_create(verbopt: options[:verbose], debugopt: options[:debug], filter: options[:filter])
|
23
26
|
end
|
24
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfs_mgmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aran Cox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|