aboutsummaryrefslogtreecommitdiff
path: root/custom/zfsrollback
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-01-19 09:49:38 -0600
committerCraig Jennings <c@cjennings.net>2026-01-19 09:49:38 -0600
commitb9afe87e1b20fad687c150bd3829db84322dcfc8 (patch)
tree97c0f420501c06ce554a1041ad9945e73087fb1b /custom/zfsrollback
parentc6d9fc785211a3388cae27001698eaf7985f3796 (diff)
downloadarchangel-b9afe87e1b20fad687c150bd3829db84322dcfc8.tar.gz
archangel-b9afe87e1b20fad687c150bd3829db84322dcfc8.zip
Fix zfsrollback to process children before parents
Sort datasets by path depth (deepest first) before rolling back. ZFS requires children to be rolled back before their parents, otherwise rollback can fail or skip datasets.
Diffstat (limited to 'custom/zfsrollback')
-rwxr-xr-xcustom/zfsrollback5
1 files changed, 3 insertions, 2 deletions
diff --git a/custom/zfsrollback b/custom/zfsrollback
index b68e11a..ee858f6 100755
--- a/custom/zfsrollback
+++ b/custom/zfsrollback
@@ -95,8 +95,9 @@ else
exit 0
fi
- # Find all datasets with this snapshot
- mapfile -t targets < <(echo "$snapshots" | grep "@${snap_name}$")
+ # Find all datasets with this snapshot, sorted by depth (deepest first)
+ # This ensures children are rolled back before parents
+ mapfile -t targets < <(echo "$snapshots" | grep "@${snap_name}$" | awk -F'@' '{print length($1), $0}' | sort -rn | cut -d' ' -f2-)
if [ ${#targets[@]} -eq 0 ]; then
echo "Error: No datasets found with snapshot @${snap_name}"