auto snapshots with zfs plugin

    • OMV 2.x

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 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 ?
    • xavierlun wrote:

      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.
    • nicjo814 wrote:

      That creates the proper cron jobs I guess?
      In cron tab added following

      Source Code

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


      autosnapshot:

      Shell-Script

      1. #!/bin/sh
      2. #
      3. # Part of NAS4Free (http://www.nas4free.org).
      4. # Copyright (c) 2012-2015 The NAS4Free Project <info@nas4free.org>.
      5. # All rights reserved.
      6. #
      7. TAG="Auto Snapshot"
      8. NOW=`/bin/date +%s`
      9. NOWHM=`/bin/date -j -f "%s" $NOW "+%H00"`
      10. autosnapshot_config="/var/etc/autosnapshot.conf"
      11. cat $autosnapshot_config | while read _type _path _name _recursive _timeday _timewday _timehour _timemin _lifetime _lifetimesec; do
      12. if [ -z "${_type}" ]; then continue; fi
      13. if [ "${_type}" != "daily" ]; then continue; fi
      14. #echo "$_type $_path $_name $_recursive $_timehour $_lifetime"
      15. if [ "$NOWHM" != "${_timehour}" ]; then continue; fi
      16. # current snapshot name
      17. name=`/bin/date -j -f "%s" $NOW "+${_name}"`
      18. if [ -z $name ]; then continue; fi;
      19. snapshot="${_path}@${name}"
      20. # oldest snapshot name
      21. TODAY=`date -j -f "%s" $NOW +%F`
      22. TODAYEPOCH=`date -j -f "%F %T" "$TODAY 12:00:00" +%s`
      23. DELEPOCH=`/bin/expr $TODAYEPOCH - ${_lifetimesec}`
      24. DELDAY=`date -j -f "%s" $DELEPOCH +%F`
      25. delname=`/bin/date -j -f "%F %H%M" "$DELDAY $NOWHM" "+${_name}"`
      26. if [ -z $delname ]; then continue; fi;
      27. delsnapshot="${_path}@${delname}"
      28. opt=""
      29. if [ "${_recursive}" = "true" ]; then
      30. opt="$opt -r"
      31. fi
      32. cmd="/sbin/zfs snapshot $opt $snapshot"
      33. delcmd="/sbin/zfs destroy $opt $delsnapshot"
      34. /usr/bin/logger -t "$TAG" "$cmd"
      35. eval "$cmd >/dev/null 2>&1"
      36. if [ ${_lifetimesec} -ne 0 ]; then
      37. /usr/bin/logger -t "$TAG" "$delcmd"
      38. eval "$delcmd >/dev/null 2>&1"
      39. fi
      40. done
      Display All


      autoshapshot.conf:

      Source Code

      1. ​daily data auto-%Y%m%d-%H0000 false * * 2000 0000 30d 2678400

      The post was edited 1 time, last by ab5031 ().