zfsonlinux / zfs-auto-snapshot

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

easier exclude only a small number of datasets from the total no of datasets #20

Closed mailinglists35 closed 10 years ago

mailinglists35 commented 11 years ago

I need to be able to exclude only certain datasets but without setting "com.sun:auto-snapshot" on all other datasets. Now it works the other way, it excludes all but those I specify. The current model of "--default-exclude" requires setting an attribute on all datasets in order to include them. I wish this was simpler so that when using a similar "--default-exclude"-like parameter there will be no need to set com.sun:auto-snapshot on all datasets but only set "com.sun:auto-snapshot"-like on the dataset I wish to exclude. thanks and sorry for my non-native english, hope you understand what I meant.

dajhorn commented 11 years ago

This is expected behavior if the --default-exclude switch is omitted. The basic zfs-auto-snapshot // invocation runs snapshots for all datasets in all pools. Setting com.sun:auto-snapshot = false excludes datasets according to the rules of ZFS property inheritance.

Note that the property value must be exactly false or it will be ignored. For example, setting com.sun:auto-snapshot = 0 doesn't work.

Remember that you can change the // to an argument list like zfs-auto-snapshot -r tank backups/machine1 backups/machine2.

If this isn't a good answer, then please post a zfs list, describe what the script is actually doing, and describe what the script should be doing.

mailinglists35 commented 11 years ago

Oh, you made it clearer, thanks! My zfs datasets are (some dataset names omitted due to their sensitive names) root@homerouter:~# zfs list -H homebackup 764G 150G 136K none homebackup/homerouter 15.4G 150G 15.1G /mnt/homerouter homebackup/iphone51 2.16G 150G 1.68G /mnt/iphone51 homebackup/ntfs 720G 150G 714G -

If I run zfs-auto-snapshot I get this:

A. without --default-exclude

  1. with com.sun:auto-snapshot unset: all datasets snapshotted
  2. with parent dataset false, all descendents true: all datasets but the parent snapshotted

B with --default-exclude

  1. with com.sun:auto-snapshot unset: no dataset snapshotted
  2. with parent dataset false, all descendents true: parent not snapshotted, descendants snapshotted

I want to prevent just the parent dataset from being zfs-auto-snapshotted without manually setting com.sun:auto-snapshot=true on all descendant datasets.

After re-reading the zfs manual I think inheritance is preventing me to set com.sun:auto-snapshot just on the parent. I don't see how zfs-auto-snapshot could workaround that... :( Maybe that would fall into wishlist category with some special --exclude-parent option (and preventing --exclude-parent and --default-exclude to be invoked simultaneously)

jeff-dagenais commented 11 years ago

Just a thought but... if the parent dataset only contains child datasets (i.e. no actual files in it, looks like it from your zfs list output), the cost of snapshotting it also is practically zero. So maybe you shouldn't bother too much about it.

If you do have files in the root dataset that need to have different zfs properties (namely com.sun:auto-snapshot), then consider moving the data into a child dataset reserved for those files. Then you'll be able to control the snapshotting independently and live better with the current behaviour.

dajhorn commented 11 years ago

@mailinglists35, this sounds like correct and expected behavior. The suggestion from @jeff-dagenais is an easy way to get the desired result.

mailinglists35 commented 11 years ago

Yes, there is no data in the parent dataset. It was just a visual annoyance to see it listed when looking at the snapshot list. I understand and I don't mind if that would be too much work in zfs-auto-snapshot code for the feature request. zfs-auto-snapshot is already a valuable tool the way it is. cheers!

mk01 commented 11 years ago

@mailinglists35 I had the same "logic" issue - wasn't used to think the "inherited way" and could not get used to it - how zfs-auto-snapshot is handling the childs. I was reviewing the original SUNW code and have the feeling it wasn't like this. ;)

I changed it back in my fork, you can take the 20 lines responsible for building filesystem list to snapshot. https://github.com/mk01/zfs-auto-snapshot/blob/master/src/zfs-auto-snapshot.sh

dajhorn commented 10 years ago

I'm closing this ticket as stale given this this comment and a lack of any other me-toos.