ZFS Cron jobs

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

TurboAAA

New Member
Oct 17, 2018
4
0
1
I am having problems with zfs cron jobs. I want a daily snapshot but nothing happens. At first I had a shell script that cron would call, but that is not working and I am not getting output from the command. I tried placing the command natively in cron without success, and I copied someone else's example and still no dice. SELinux shows no violations.

Here is the example I copied, very similar to mine.
@daily /usr/sbin/zfs snapshot -r raid5@AutoD-`date +"_%F"`

Thoughts?

[root@nas ~]# yum info zfs
...
Name : zfs
Arch : x86_64
Version : 0.7.11
Release : 1.el7_4

[root@nas ~]# uname -r
3.10.0-862.14.4.el7.x86_64

[root@nas ~]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)

[root@nas ~]# sealert -a /var/log/audit/audit.log
100% done
found 0 alerts in /var/log/audit/audit.log
 

TeeJayHoward

Active Member
Feb 12, 2013
376
112
43
Here's what I use for 30-day rolling snapshots (ZFS on Linux):

Code:
1  1 * * * /usr/bin/rsync -av --delete /pool/ /backup/ 2>> /var/log/rsync.errors
1  0 * * * /usr/sbin/zfs snapshot -r backup@`date +\%Y-\%m-\%d` 2>> /var/log/zfs.snapshot
0  2 * * * /usr/sbin/zfs destroy -r backup@`date -d -30days +\%Y-\%m-\%d` 2>> /var/log/zfs.destroy
 

BLinux

cat lover server enthusiast
Jul 7, 2016
2,672
1,081
113
artofserver.com
i can't say why your cron jobs aren't working; you may want to start by seeing if cron is even running the job in /var/log/cron.

however, if all you want is ZFS rolling snapshots, zfs-auto-snapshot is the package I would recommend. For CentOS7, you can install this repo:

poettlerric/zfs-auto-snapshot Copr

And then:

$ yum install zfs-auto-snapshot

That's pretty much all there is to it.

on a side note, you have the .el7_4 zfs repo, but your CentOS version is 7.5. You may want to update your zfs-release package to the .el7_5 version, and then reinstall zfs packages.
 

TurboAAA

New Member
Oct 17, 2018
4
0
1
When I get home this evening I will dig a little deeper into the suggestions made. Thanks to everyone for their ideas.

Cron is running and I see it in the cron log.
When I was using a shell script, the cron job would run and any command that wrote to a file would do so without issue. But the zfs component would not run at all.

It is very bazaar as I have not seen this on any of the other servers I manage.
 

TurboAAA

New Member
Oct 17, 2018
4
0
1
So, my face is red. I did not escape special characters in either my script or the direct cron lines. The evidence was in front of me and I simply glanced over it.

Thanks for the help everyone.