ZFS Cron jobs

Discussion in 'Linux Admins, Storage and Virtualization' started by TurboAAA, Oct 17, 2018.

  1. TurboAAA

    TurboAAA New Member

    Joined:
    Oct 17, 2018
    Messages:
    4
    Likes Received:
    0
    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
     
    #1
  2. vudu

    vudu New Member

    Joined:
    Dec 30, 2017
    Messages:
    14
    Likes Received:
    2
    #2
  3. TeeJayHoward

    TeeJayHoward Active Member

    Joined:
    Feb 12, 2013
    Messages:
    361
    Likes Received:
    105
    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
     
    #3
    BackupProphet, TurboAAA and gigatexal like this.
  4. BLinux

    BLinux Well-Known Member

    Joined:
    Jul 7, 2016
    Messages:
    1,863
    Likes Received:
    523
    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.
     
    #4
    dswartz and TurboAAA like this.
  5. TurboAAA

    TurboAAA New Member

    Joined:
    Oct 17, 2018
    Messages:
    4
    Likes Received:
    0
    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.
     
    #5
  6. TurboAAA

    TurboAAA New Member

    Joined:
    Oct 17, 2018
    Messages:
    4
    Likes Received:
    0
    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.
     
    #6
Similar Threads: Cron jobs
Forum Title Date
Linux Admins, Storage and Virtualization Micron P420m on Proxmox or ZoL Mar 28, 2016

Share This Page