zfsonlinux / zfs-auto-snapshot

ZFS Automatic Snapshot Service for Linux
GNU General Public License v2.0
853 stars 246 forks source link

z-a-s -r fails to run recursively when a child has com.sun:auto-snapshot=false #24

Open justinpryzby opened 10 years ago

justinpryzby commented 10 years ago

justinp@backup:~$ time sudo ./zfs-auto-snapshot.real -d -s -r -k 32 -l x rpool Debug: Including rpool for regular snapshot. Doing regular snapshots of rpool Debug: zfs snapshot -o com.sun:auto-snapshot-desc='-' 'rpool@zfs-auto-snap_x-2014-02-18-1513' @zfs-auto-snap_x-2014-02-18-1513, 1 created, 0 destroyed, 0 warnings.

justinp@backup:~$ zfs get -H com.sun:auto-snapshot rpool/dump rpool/swap rpool/dump com.sun:auto-snapshot false local rpool/swap com.sun:auto-snapshot false local

The relevant logic that leads to this behavior is commented as:

Exclude datasets that are not named on the command line.

AND,

Check whether the candidate name is a prefix of any excluded dataset name.

Seems if [ -n "$opt_recursive" ], then all CANDIDATES should be included which is a decendent of an argument on the cmdline? [ "${ii#$jj/}" != "$ii" ]

dajhorn commented 10 years ago

@justinpryzby, I recall that this behavior is for quirk compatibility with Solaris. If not, then we'll fix it.

I'm pretty sure this behavior is given in some best practices documentation as one reason to keep the top-level rpool dataset empty. For example:

Where zfs set com.sun:auto-snapshot true rpool/MyFiles produces the desired behavior.

justinpryzby commented 10 years ago

Thanks for your comment. I guess you mean that rpool is empty, but has sub-filesystems (dump,swap,MyFiles). Setting com.sun:auto-snapshot=true doesn't produce the intended behavior of zfs-auto-snapshot -r rpool, doing a non-recursive snapshot due to the setting of auto-snapshot=false at rpool/swap.

abclution commented 9 years ago

This question doesn't seem answered to me. I am having a similar problem.

zfs-auto-snapshot --recursive --verbose --debug --label=hourly --keep=337 mypool-8tb Debug: Including mypool-8tb for regular snapshot. Doing regular snapshots of mypool-8tb Debug: zfs snapshot -o com.sun:auto-snapshot-desc='-' 'mypool-8tb@zfs-auto-snap_hourly-2015-02-10-0203' @zfs-auto-snap_hourly-2015-02-10-0203, 1 created, 0 destroyed, 0 warnings.

zfs list -t snap mypool-8tb@zfs-auto-snap_hourly-2015-02-10-0203

How the heck am I supposed to run a recursive selective snapshot when setting any childs for exclusions makes the entire recursive snapshot fail? Am I missing something?

abclution commented 9 years ago

I got this answered in irc.

Changing the snapshot command to include the additional datasets works. zfs-auto-snapshot --recursive --verbose --debug --label=hourly --keep=337 mypool-8tb /mypool-8tb/H-Drive

FransUrbo commented 9 years ago

Try calling with // instead of pool name. Then it works as intended/wanted.

FransUrbo commented 9 years ago

Seems to be a duplicate of #37.