Skip to content

Commit

Permalink
Use TARGETS_REGULAR if the recursive flag is not set
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jigpu authored and Guiorgy committed Aug 24, 2024
1 parent fdc4e42 commit c11dfb7
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/zfs-auto-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,24 @@ do
fi
done

# Append this candidate to the recursive snapshot list because it:
# Append this candidate to the snapshot list because it:
#
# * Does not have an exclusionary property.
# * Is in a pool that can currently do snapshots.
# * Does not have an excluded descendent filesystem.
# * Is not the descendant of an already included filesystem.
#
print_log debug "Including $ii for recursive snapshot."
TARGETS_RECURSIVE="${TARGETS_RECURSIVE:+$TARGETS_RECURSIVE }$ii" # nb: \t
if [ -z "$opt_recursive" ]
then
print_log debug "Including $ii for regular snapshot."
TARGETS_REGULAR="${TARGETS_REGULAR:+$TARGETS_REGULAR }$ii" # nb: \t
else
# Append this candidate to the recursive snapshot list because it additionally:
#
# * Does not have an excluded descendent filesystem.
# * Is not the descendant of an already included filesystem.
#
print_log debug "Including $ii for recursive snapshot."
TARGETS_RECURSIVE="${TARGETS_RECURSIVE:+$TARGETS_RECURSIVE }$ii" # nb: \t
fi
done

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

0 comments on commit c11dfb7

Please sign in to comment.