zfs_mgmt 0.10.1 → 0.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0773d86f0e8c33cf8f595af183d1270c4f9955b7be4d078eb8179ecb67075771
4
- data.tar.gz: 6c2aef4c7b7f6a148371efa0f3a9cbb99fc2f07a4a07486d7d366739e5372439
3
+ metadata.gz: ed488b7ef9e1daf716d09e8b207c0ca75430e3499d350bfeb04127d83c5547cb
4
+ data.tar.gz: e0e694cc49c8bc8de9f034a22bcd1393481b7d602b72f20824553a07e63b3e4d
5
5
  SHA512:
6
- metadata.gz: bef8db811af46e9d3528b9f7f3e8b7d02846d635714790878c8a506375f64616321325e7b183582949914b12cf1c94a6e78f1ce61f43d69c46d688ceba1eff3c
7
- data.tar.gz: ebf3dfdbc3c0af47199701d18817e206fc08e9585821f242e8b6a9153b70aecab8ffc732176d13637313e506270f89f9ca537afc99262e75a3194de4920f2934
6
+ metadata.gz: 2850592f17007a69dbdf83bc2d8d7bc7471f808954177fdeee76b139408f7a26cdf8b1ada0d721565c963ed062bdcc08779cf15982207cd5d96598a5fa7f103f
7
+ data.tar.gz: 42539cd9e5bc3d3b7fbe4ed531c1577f1152cbdfdec4e41ccedb00eb3133c2b361d7bdae399274161a0650991a48c04d3d189188625d5fe7868627798f2de3ff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zfs_mgmt (0.10.1)
4
+ zfs_mgmt (0.11.0)
5
5
  deep_merge
6
6
  easy_talk
7
7
  filesize (~> 0.2)
data/README.md CHANGED
@@ -224,7 +224,7 @@ Dataset options configured in TOML inherit to child datasets (e.g. `tank` -> `ta
224
224
 
225
225
  `destination` in `[zfs."pool/dataset"]` accepts either a single string or an array of strings (for example `destination = ["backup/tank", "zfs_recv@offsite.example.com:offsite/tank"]`) to send a dataset to multiple destinations.
226
226
 
227
- `source` in `[zfs."pool/dataset"]` accepts a single string (for example `source = "zfs_send@prod.example.com:tank"`) paired with `recv = true` (or `recv = "local"`) to pull snapshots into the local dataset via `zfsmgr recv all` (including datasets defined only in TOML config that have not yet been created locally).
227
+ `source` in `[zfs."pool/dataset"]` accepts a single string specifying the exact source dataset (for example `source = "zfs_send@prod.example.com:tank/data"` or a top-level pool `source = "zfs_send@prod.example.com:data"`) paired with `recv = true` (or `recv = "local"`) to pull snapshots into the local dataset via `zfsmgr recv all` (including datasets defined only in TOML config that have not yet been created locally).
228
228
 
229
229
  Unlike scalar options (where a higher-precedence source replaces lower ones), `excludes`, `overrides`, and `ssh_config` are **merged** from lowest precedence (`zfsmgmt:excludes` / `zfsmgmt:overrides` / `zfsmgmt:ssh_config`, with `ssh_config` prefilled with `BatchMode = "yes"`) up through top-level config, per-dataset config (ancestor to child), and CLI `--exclude` / `--option` flags (for `excludes`/`overrides`). To unset a value set at a lower precedence level, use the `**` knockout prefix:
230
230
  - In `overrides` / `ssh_config`: set `prop = "**"` in TOML (or `prop=**` / `**prop` in `zfsmgmt:*` or CLI `--option`) to remove `prop` from lower levels, or `"**"` alone to clear all lower-level options.
@@ -406,14 +406,14 @@ Enable `zfs recv` (pulling snapshots from `zfsmgmt:source`) for this dataset via
406
406
  `zfsmgr recv all` runs `zfs send` on the source side (over SSH using `ssh_config` when `zfsmgmt:source` specifies `[user@]host:`) and `zfs recv` on the local dataset. Transfer results are recorded in the shared send/recv state database keyed by `(source, destination)` with `operation = "recv"`, visible in `zfsmgr state` (`zfsmgr state --check` emits `zfs_recv` status lines).
407
407
 
408
408
  ### zfsmgmt:source
409
- Base source ZFS dataset path for `zfsmgr recv all` (required when `zfsmgmt:recv` is enabled; configured via ZFS user property or TOML config, not a CLI option). Supports local and remote forms:
410
- - `zpool/zfs/zfs2` (local)
411
- - `hostname:zpool/zfs/zfs2` (remote via SSH)
412
- - `user@hostname:zpool/zfs/zfs2` (remote via SSH with user)
409
+ Exact source ZFS dataset path for `zfsmgr recv all` (required when `zfsmgmt:recv` is enabled; configured via ZFS user property or TOML config, not a CLI option). Supports local and remote forms (including top-level pools and differently named local targets):
410
+ - `data` or `zpool/zfs/zfs2` (local)
411
+ - `hostname:data` or `hostname:zpool/zfs/zfs2` (remote via SSH)
412
+ - `user@hostname:data` or `user@hostname:zpool/zfs/zfs2` (remote via SSH with user)
413
413
 
414
- Path resolution rules (analogous to `zfsmgmt:destination`):
415
- - When the property's ZFS source is `local`, the source path resolves to `<source>/<dataset basename>`.
416
- - When the property's ZFS source is `inherited from <ancestor>`, the source path resolves to `<source>/<ancestor basename>/<relative path>`.
414
+ Path resolution rules:
415
+ - When the property's ZFS source is `local`, the source path resolves directly to `<source>` (no local dataset basename is appended).
416
+ - When the property's ZFS source is `inherited from <ancestor>`, the source path resolves to `<source>/<relative path below ancestor>`.
417
417
  - When the property's ZFS source is `received` (or unrecognized), no source is resolved.
418
418
 
419
419
  ### zfs send / recv flags
data/examples/config.toml CHANGED
@@ -129,7 +129,7 @@ restic_repository = "/srv/restic/zfs"
129
129
 
130
130
  # Receiving parent dataset: source inherits to children for `zfsmgr recv all`
131
131
  [zfs."backup/prod"]
132
- source = "zfs_send@prod.example.com:tank"
132
+ source = "zfs_send@prod.example.com:tank/prod"
133
133
 
134
134
  [zfs."backup/prod/data"]
135
135
  recv = true # true, false, or "local" (only recv this dataset)
@@ -1,3 +1,3 @@
1
1
  module ZfsMgmt
2
- VERSION = "0.10.1"
2
+ VERSION = "0.11.0"
3
3
  end
data/lib/zfs_mgmt/zfs.rb CHANGED
@@ -407,8 +407,11 @@ module ZfsMgmt
407
407
  return source unless override
408
408
 
409
409
  ov_remote, ov_path = ZfsMgmt.parse_destination(override)
410
- rel = @source_relative_path || File.basename(name)
411
- ZfsMgmt.format_destination(ov_remote, File.join(ov_path, rel))
410
+ return nil if ov_path.nil? || ov_path.empty?
411
+
412
+ rel = @source_relative_path.to_s
413
+ joined = rel.empty? ? ov_path : File.join(ov_path, rel)
414
+ ZfsMgmt.format_destination(ov_remote, joined)
412
415
  end
413
416
 
414
417
  def self.relative_path_for(name, prop_src)
@@ -419,6 +422,16 @@ module ZfsMgmt
419
422
  end
420
423
  end
421
424
 
425
+ def self.source_relative_path_for(name, prop_src)
426
+ if prop_src == "local"
427
+ ""
428
+ elsif prop_src && (m = /\Ainherited from (.+)\z/.match(prop_src))
429
+ ancestor = m[1]
430
+ prefix = "#{ancestor}/"
431
+ name.start_with?(prefix) ? name.delete_prefix(prefix) : ""
432
+ end
433
+ end
434
+
422
435
  def self.warn_unknown_zfs_props(name, props)
423
436
  props.each_key do |key|
424
437
  key_str = key.to_s
@@ -493,21 +506,27 @@ module ZfsMgmt
493
506
  prop_remote = nil if prop_remote && prop_remote.to_s.empty?
494
507
  rel = relative_path_for(name, dest_src)
495
508
  if rel && !dest_bases.empty?
496
- entries = dest_bases.map do |dest_base|
509
+ entries = dest_bases.each_with_object([]) do |dest_base, acc|
497
510
  explicit_remote, base_path = ZfsMgmt.parse_destination(dest_base)
511
+ if base_path.nil? || base_path.empty?
512
+ ZfsMgmt.logger&.warn("ignoring destination '#{dest_base}' on #{name}: missing dataset path")
513
+ next
514
+ end
498
515
  effective_remote = explicit_remote || prop_remote
499
- {
516
+ acc << {
500
517
  resolved: ZfsMgmt.format_destination(effective_remote, File.join(base_path, rel)),
501
518
  base: ZfsMgmt.format_destination(effective_remote, base_path),
502
519
  explicit_remote: explicit_remote
503
520
  }
504
521
  end
505
- as_array = raw_dest_prop.is_a?(Array) || entries.length > 1
506
- attrs[:destination] = as_array ? entries.map { |e| e[:resolved] } : entries.first[:resolved]
507
- attrs[:destination_base] = as_array ? entries.map { |e| e[:base] } : entries.first[:base]
508
- attrs[:destination_explicit_remote] = (entries.length == 1) ? entries.first[:explicit_remote] : nil
509
- attrs[:destination_entries] = entries
510
- attrs[:destination_relative_path] = rel
522
+ unless entries.empty?
523
+ as_array = raw_dest_prop.is_a?(Array) || entries.length > 1
524
+ attrs[:destination] = as_array ? entries.map { |e| e[:resolved] } : entries.first[:resolved]
525
+ attrs[:destination_base] = as_array ? entries.map { |e| e[:base] } : entries.first[:base]
526
+ attrs[:destination_explicit_remote] = (entries.length == 1) ? entries.first[:explicit_remote] : nil
527
+ attrs[:destination_entries] = entries
528
+ attrs[:destination_relative_path] = rel
529
+ end
511
530
  end
512
531
  end
513
532
 
@@ -535,14 +554,19 @@ module ZfsMgmt
535
554
  if props.key?("zfsmgmt:source")
536
555
  raw_source_prop = props["zfsmgmt:source"]
537
556
  source_src = props["zfsmgmt:source@source"]
538
- rel = relative_path_for(name, source_src)
539
- if rel && raw_source_prop.is_a?(String) && !raw_source_prop.strip.empty?
557
+ rel = source_relative_path_for(name, source_src)
558
+ if !rel.nil? && raw_source_prop.is_a?(String) && !raw_source_prop.strip.empty?
540
559
  source_base = raw_source_prop.strip
541
560
  explicit_remote, base_path = ZfsMgmt.parse_destination(source_base)
542
- attrs[:source] = ZfsMgmt.format_destination(explicit_remote, File.join(base_path, rel))
543
- attrs[:source_base] = ZfsMgmt.format_destination(explicit_remote, base_path)
544
- attrs[:source_explicit_remote] = explicit_remote
545
- attrs[:source_relative_path] = rel
561
+ if base_path.nil? || base_path.empty?
562
+ ZfsMgmt.logger&.warn("ignoring source '#{source_base}' on #{name}: missing dataset path")
563
+ else
564
+ resolved_path = rel.empty? ? base_path : File.join(base_path, rel)
565
+ attrs[:source] = ZfsMgmt.format_destination(explicit_remote, resolved_path)
566
+ attrs[:source_base] = ZfsMgmt.format_destination(explicit_remote, base_path)
567
+ attrs[:source_explicit_remote] = explicit_remote
568
+ attrs[:source_relative_path] = rel
569
+ end
546
570
  end
547
571
  end
548
572
 
data/lib/zfs_mgmt.rb CHANGED
@@ -19,7 +19,7 @@ require "digest"
19
19
 
20
20
  module ZfsMgmt
21
21
  KNOCKOUT_PREFIX = "**".freeze
22
- DESTINATION_REMOTE_RE = /\A((?:[^@:\/\s]+@)?[^:\/\s]+):(.+)\z/
22
+ DESTINATION_REMOTE_RE = /\A((?:[^@:\/\s]+@)?[^:\/\s]+):(.*)\z/
23
23
 
24
24
  DATE_PATTERNS = {
25
25
  "hourly" => "%F Hour %H",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zfs_mgmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aran Cox