Using the below zfs-auto-snapshot commands, how to specify to keep 52 weekly snapshots and infinite number of monthly snapshots?

sudo zfs set com.sun:auto-snapshot=true storage
sudo zfs set com.sun:auto-snapshot:weekly=true storage
sudo zfs set com.sun:auto-snapshot:monthly=true storage

When I specified it as a keyword or argument it failed both times:

sudo zfs set com.sun:auto-snapshot:weekly=true storage keep=52
cannot open 'keep=52': invalid dataset name

sudo zfs set com.sun:auto-snapshot:weekly=true storage --keep=52
cannot open '--keep=52': invalid dataset name
up vote 1 down vote accepted

Here is a sample of one of my system's /etc/cron.d/zfs-auto-snapshot.


*/5 * * * * root /sbin/zfs-auto-snapshot -q -g --label=frequent --keep=24 //
00 * * * * root /sbin/zfs-auto-snapshot -q -g --label=hourly --keep=24 //
59 23 * * * root /sbin/zfs-auto-snapshot -q -g --label=daily --keep=14 //
59 23 * * 0 root /sbin/zfs-auto-snapshot -q -g --label=weekly --keep=4 //
00 00 1 * * root /sbin/zfs-auto-snapshot -q -g --label=monthly --keep=18 //
  • Running > /usr/sbin/zfs-auto-snapshot -q -g --label=frequent --keep=24 results in: bash: /usr/sbin/zfs-auto-snapshot: No such file or directory. If I run > which zfs-auto-snapshot, I get: /usr/local/sbin/zfs-auto-snapshot. I then tried > zfs-auto-snapshot -q -g --label=frequent --keep=24 which returned Error: The filesystem argument list is empty.. Do those commands work on Ubuntu? – Greg Jun 16 '17 at 1:37
  • Please don't run > anything, especially as root, unless you know for a fact that you really want to do this. A bare > x will truncate the file x, causing loss of data, and parameters intended for x (if it is an executable) will likely not help you there. @Dave, if you want to illustrate the shell prompt, use $ or # as those are the common symbols for ordinary user and superuser prompts, respectively. Or just leave it out entirely. – a CVn Jul 8 '17 at 13:23

You need to edit the invocation of zfs-auto-snapshot. The file should be located in /etc/cron.weekly/zfs-auto-snapshot. There a default value of 8 is set.

I personally didn't know about this tool before. What I use is zfSnap. It's available in the standard repositories.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.