zfs_mgmt 0.3.4 → 0.3.5
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/README.md +5 -1
- data/bin/zfsmgr +3 -1
- data/lib/zfs_mgmt.rb +11 -3
- data/lib/zfs_mgmt/restic.rb +33 -0
- data/lib/zfs_mgmt/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bce5f90411d08b54334f8694e7956f718c1e63995f2c799b95cb170b302c2c8a
|
4
|
+
data.tar.gz: 1d82a41657f40fe371814210be392d8c34be333816530fcff6a67ae778dc120b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e500b4cc3b155528c470c5aa26338a948e783a5f951a7a5e0d6c05b6739c07cccd6bfe0a1dd001a34722f47e611cc85e2f931d8e3cbca58e37b0f3b0d23606da
|
7
|
+
data.tar.gz: d3ca6969f760260449f85d99e05133f542700f9d0322a84f771cd157d3ec0729c2e86dc33f0326c53b1f35065cb28b879bbad85c6e422c4bae95b20cc9d21f06
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -180,7 +180,11 @@ oldest and unless the property is set to youngest oldest will be used.
|
|
180
180
|
### zfsmgmt:snapshot
|
181
181
|
If this property is 'true' then create a snapshot in the format of
|
182
182
|
zfsmgmt-%FT%T%z. If this property is 'recursive' then create a
|
183
|
-
recursive snapshot of this zfs
|
183
|
+
recursive snapshot of this zfs, but only on zfs where this property is
|
184
|
+
local. If this property is set to the string 'local' and the property
|
185
|
+
is set locally, it will create a snapshot. The intention is that you
|
186
|
+
would use 'local' when you want a zfs snapshot for the filesystem, but
|
187
|
+
NOT it's descendant filesystems.
|
184
188
|
|
185
189
|
### zfsmgmt:snap_prefix
|
186
190
|
Change the zfsmgmt portion of created snapshots, ie: 'autosnap' would
|
data/bin/zfsmgr
CHANGED
@@ -36,7 +36,9 @@ class ZfsMgr < Thor
|
|
36
36
|
desc "snapshot SUBCOMMAND ...ARGS", "manage snapshots"
|
37
37
|
subcommand "snapshot", Snapshot
|
38
38
|
desc "list SUBCOMMAND ...ARGS", "list filesystems"
|
39
|
-
subcommand "list",
|
39
|
+
subcommand "list", ZfsMgmtList
|
40
|
+
desc "restic SUBCOMMAND ...ARGS", "backup zfs to restic"
|
41
|
+
subcommand "restic", ZfsMgmtRestic
|
40
42
|
end
|
41
43
|
|
42
44
|
ZfsMgr.start(ARGV)
|
data/lib/zfs_mgmt.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require "zfs_mgmt/version"
|
3
|
+
require "zfs_mgmt/restic"
|
3
4
|
require 'pp'
|
4
5
|
require 'date'
|
5
6
|
require 'logger'
|
@@ -310,8 +311,15 @@ module ZfsMgmt
|
|
310
311
|
end
|
311
312
|
dt = DateTime.now
|
312
313
|
zfsget(properties: custom_properties()).each do |zfs,props|
|
314
|
+
unless /#{filter}/ =~ zfs
|
315
|
+
next
|
316
|
+
end
|
313
317
|
# zfs must have snapshot set to true or recursive
|
314
|
-
if props.has_key?('zfsmgmt:snapshot') and
|
318
|
+
if props.has_key?('zfsmgmt:snapshot') and
|
319
|
+
props['zfsmgmt:snapshot'] == 'true' or
|
320
|
+
( props['zfsmgmt:snapshot'] == 'recursive' and props['zfsmgmt:snapshot@source'] == 'local' ) or
|
321
|
+
( props['zfsmgmt:snapshot'] == 'local' and props['zfsmgmt:snapshot@source'] == 'local' )
|
322
|
+
|
315
323
|
prefix = ( props.has_key?('zfsmgmt:snap_prefix') ? props['zfsmgmt:snap_prefix'] : 'zfsmgmt' )
|
316
324
|
ts = ( props.has_key?('zfsmgmt:snap_timestamp') ? props['zfsmgmt:snap_timestamp'] : '%FT%T%z' )
|
317
325
|
com = ['zfs','snapshot']
|
@@ -325,7 +333,7 @@ module ZfsMgmt
|
|
325
333
|
end
|
326
334
|
end
|
327
335
|
end
|
328
|
-
class
|
336
|
+
class ZfsMgmtList < Thor
|
329
337
|
class_option :filter, :type => :string, :default => '.+',
|
330
338
|
:desc => 'only act on zfs matching this regexp'
|
331
339
|
desc "stale", "list all zfs with stale snapshots"
|
@@ -340,7 +348,7 @@ class ZfsMgrList < Thor
|
|
340
348
|
last = snaps.keys.sort { |a,b| snaps[a]['creation'] <=> snaps[b]['creation'] }.last
|
341
349
|
snap_time = Time.at(snaps[last]['creation'])
|
342
350
|
if snap_time < cutoff
|
343
|
-
table.rows << [zfs,last,snap_time]
|
351
|
+
table.rows << [zfs,last.split('@')[1],snap_time]
|
344
352
|
end
|
345
353
|
end
|
346
354
|
if table.rows.count > 0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module ZfsMgmt::Restic
|
3
|
+
def self.backup(backup_type: 'incremental', force: false, filter: '.+')
|
4
|
+
pp backup_type, force, filter
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class ZfsMgmtResticBackup < Thor
|
9
|
+
class_option :filter, :type => :string, :default => '.+',
|
10
|
+
:desc => 'only act on zfs matching this regexp'
|
11
|
+
class_option :force, :type => :boolean, :default => false,
|
12
|
+
:desc => 'force create this backup type, fail if it cannot be forced'
|
13
|
+
desc "incremental", "perform incremental backup"
|
14
|
+
def incremental()
|
15
|
+
ZfsMgmt::Restic.backup(backup_type: 'incremental', force: options[:force])
|
16
|
+
end
|
17
|
+
desc "differential", "perform differential backup"
|
18
|
+
def differential()
|
19
|
+
ZfsMgmt::Restic.backup(backup_type: 'differential', force: options[:force])
|
20
|
+
end
|
21
|
+
desc "full", "perform full backup"
|
22
|
+
def full()
|
23
|
+
ZfsMgmt::Restic.backup(backup_type: 'full', force: options[:force])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ZfsMgmtRestic < Thor
|
28
|
+
desc "restic SUBCOMMAND ...ARGS", "backup all configured zfs to restic"
|
29
|
+
subcommand "backup", ZfsMgmtResticBackup
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
data/lib/zfs_mgmt/version.rb
CHANGED
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.5
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- bin/zfssendman
|
126
126
|
- bin/zfssnapman
|
127
127
|
- lib/zfs_mgmt.rb
|
128
|
+
- lib/zfs_mgmt/restic.rb
|
128
129
|
- lib/zfs_mgmt/version.rb
|
129
130
|
- zfs_mgmt.gemspec
|
130
131
|
homepage: https://github.com/aranc23/zfs_mgmt
|