Skip to content

Commit bce1d7e

Browse files
committed
Use TARGETS_REGULAR if the recursive flag is not set
The program currently stores all targets into `TARGETS_RECURSIVE` even if the `--recursive` flag is not set. This causes the program to incorrectly snapshot only the most-ancestral datasets in the list. For example, the following invocation would only snapshot datasets `a` and `b`: $ zfs-snapshot-auto a a\child1 a\child2 b b\child1 b\child2 Instead, we should be storing each valid dataset in `TARGETS_REGULAR` so that they can be backed up individually. This commit tests wether the flag is set before deciding whih variable to update. Fixes: zfsonlinux#83
1 parent 92db087 commit bce1d7e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,15 +567,24 @@ do
567567
fi
568568
done
569569

570-
# Append this candidate to the recursive snapshot list because it:
570+
# Append this candidate to the snapshot list because it:
571571
#
572572
# * Does not have an exclusionary property.
573573
# * Is in a pool that can currently do snapshots.
574-
# * Does not have an excluded descendent filesystem.
575-
# * Is not the descendant of an already included filesystem.
576574
#
577-
print_log debug "Including $ii for recursive snapshot."
578-
TARGETS_RECURSIVE="${TARGETS_RECURSIVE:+$TARGETS_RECURSIVE }$ii" # nb: \t
575+
if [ -z "$opt_recursive" ]
576+
then
577+
print_log debug "Including $ii for regular snapshot."
578+
TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR }$ii" # nb: \t
579+
else
580+
# Append this candidate to the recursive snapshot list because it additionally:
581+
#
582+
# * Does not have an excluded descendent filesystem.
583+
# * Is not the descendant of an already included filesystem.
584+
#
585+
print_log debug "Including $ii for recursive snapshot."
586+
TARGETS_RECURSIVE="${TARGETS_RECURSIVE:+$TARGETS_RECURSIVE }$ii" # nb: \t
587+
fi
579588
done
580589

581590
# Linux lacks SMF and the notion of an FMRI event, but always set this property

0 commit comments

Comments
 (0)