auto snapshots with zfs plugin

  • Hello


    i was waiting for btrfs support in openmediavault but it does not seem under way
    so i am switching my NAS from ext4 to ZFS which seems to be quite stable to what i hear


    (actually i have EXT4 drive and in parallel a copy of dataset with ZFS)


    up to now i am happy about the transfer



    I have one question about the usage of snapshot
    i have seen how to create a snapshot



    but i would like to know if there is any easy way in the ZFS plugin to create the snapshot automatically on schedule (maybe in the beta version)
    also to check errors it is necessary to launch some check/repaire command on a regular base ?

  • I use following for daily snapshot by cron:

    Code
    /sbin/zfs snapshot -r pool_name/dataset@AutoD-`date +"%F"`


    and "auto delete" after 7 days:

    Code
    /sbin/zfs list -t snapshot -o name | /bin/grep pool_name/dataset@AutoD- | /usr/bin/sort -r | /usr/bin/tail -n +7 | /usr/bin/xargs -n 1 /sbin/zfs destroy -r
  • maybe a nice feature of the ZFS plugin would be an interface to create those task easily


    I have been considering this, but it's extremely difficult to create a "general and intuitive" interface that at the same time needs to be specific... For now I won't add any such feature (and rather point to cron), but if someone can come up with a nice solution and send a pull request on GitHub I'm definitely willing to consider it.

  • That creates the proper cron jobs I guess?

    In cron tab added following

    Code
    # autosnapshot
    0 */1 * * * root /usr/local/sbin/autosnapshot >/dev/null 2>&1


    autosnapshot:



    autoshapshot.conf:


    Code
    daily data auto-%Y%m%d-%H0000 false * * 2000 0000 30d 2678400
  • I have an issue with autocleaning snapshots.


    Cronjob creates daily snapshot:

    Code
    /sbin/zfs snapshot -r Storage/backup@backup_`date +"%F"`



    Cronjob to check age of snapshot and deletes it after 30 days:

    Code
    /sbin/zfs list -t snapshot -o name | /bin/grep Storage/backup@backup_ | /usr/bin/sort -r | /usr/bin/tail -n +30 | /usr/bin/xargs -n 1 /sbin/zfs destroy -r


    running this job gives me


    is the missing argument because of there are no snapshots older than 30 days or is there another syntax mistake?

    Chaos is found in greatest abundance wherever order is being sought.
    It always defeats order, because it is better organized.
    Terry Pratchett

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!