source: src-sh/lpreserver/backend/zfscronsnap.sh @ 9cd0fa0

releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 9cd0fa0 was 9cd0fa0, checked in by Kris Moore <kris@…>, 6 months ago
  • Major update to life-preserver backend

Add new "automatic" mode for creating snapshots

When enabled, this will create snapshots in the following manner:

  • Snapshots will be created every 5 minutes and kept for an hour.
  • A hourly snapshot will be kept for a day.
  • A daily snapshot will be kept for a month.
  • A Monthly snapshot will be kept for a year.
  • The life-preserver daemon will also keep track of the zpool disk space, if the capacity falls below 75%, the oldest snapshot will be auto-pruned.
  • Property mode set to 100755
File size: 1.3 KB
Line 
1#!/bin/sh
2# ZFS functionality
3# Args $1 = jail-name
4# Args $2 = zfs directive
5#######################################################################
6
7# Source our functions
8PROGDIR="/usr/local/share/lpreserver"
9
10# Source our variables
11. /usr/local/share/pcbsd/scripts/functions.sh
12. ${PROGDIR}/backend/functions.sh
13
14DATASET="${1}"
15ACTION="${2}"
16
17if [ -z "${DATASET}" ]; then
18  exit_err "No dataset specified!"
19fi
20
21if [ "$ACTION" = "start" ] ; then
22
23  TIME="${3}"
24
25  if [ "$TIME" = "auto" ] ; then
26     enable_cron "$DATASET" "auto" "auto" "auto"
27     echo "Snapshot frequency set: Automatic"
28     exit 0
29  fi
30
31  # See if the user is running daily with a hour specified
32  echo $TIME | grep -q "daily"
33  if [ $? -eq 0 ] ; then
34     hour="`echo $TIME | cut -d '@' -f 2`"
35     if [ -z "$hour" ] ; then hour="22" ; fi
36     TIME="daily"
37  fi
38
39  COUNT="${4}"
40  case $TIME in
41  daily|hourly|30min|10min|5min) ;;
42        *) echo "ERROR: Invalid frequency specified!" ; exit 5 ;;
43  esac
44  if [ ! $(is_num "$COUNT") ] ; then
45     echo "ERROR: Invalid count specified!" ; exit 5
46  fi
47
48  enable_cron "$DATASET" "$TIME" "$COUNT" "$hour"
49  echo "Snapshot frequency set: $TIME @ $hour"
50  echo "Snapshot # to keep set: $COUNT"
51  exit 0
52fi
53
54if [ "$ACTION" = "stop" ] ; then
55  enable_cron "$DATASET" "OFF"
56  exit 0
57fi
58
Note: See TracBrowser for help on using the repository browser.