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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -8
- data/examples/config.toml +1 -1
- data/lib/zfs_mgmt/version.rb +1 -1
- data/lib/zfs_mgmt/zfs.rb +40 -16
- data/lib/zfs_mgmt.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed488b7ef9e1daf716d09e8b207c0ca75430e3499d350bfeb04127d83c5547cb
|
|
4
|
+
data.tar.gz: e0e694cc49c8bc8de9f034a22bcd1393481b7d602b72f20824553a07e63b3e4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2850592f17007a69dbdf83bc2d8d7bc7471f808954177fdeee76b139408f7a26cdf8b1ada0d721565c963ed062bdcc08779cf15982207cd5d96598a5fa7f103f
|
|
7
|
+
data.tar.gz: 42539cd9e5bc3d3b7fbe4ed531c1577f1152cbdfdec4e41ccedb00eb3133c2b361d7bdae399274161a0650991a48c04d3d189188625d5fe7868627798f2de3ff
|
data/Gemfile.lock
CHANGED
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
|
-
|
|
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
|
|
415
|
-
- When the property's ZFS source is `local`, the source path resolves to `<source
|
|
416
|
-
- When the property's ZFS source is `inherited from <ancestor>`, the source path resolves to `<source>/<
|
|
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)
|
data/lib/zfs_mgmt/version.rb
CHANGED
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
|
-
|
|
411
|
-
|
|
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.
|
|
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
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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 =
|
|
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
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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