source: src-sh/lpreserver/backend/zfscronsnap.sh @ f615958

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since f615958 was f615958, checked in by Kris Moore <kris@…>, 17 months ago

Update cron functionality for snapshots, allow us to specify a specific hour to
run at when doing daily snapshots

  • Property mode set to 100755
File size: 1.1 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  # See if the user is running daily with a hour specified
26  echo $TIME | grep -q "daily"
27  if [ $? -eq 0 ] ; then
28     hour="`echo $TIME | cut -d '@' -f 2`"
29     if [ -z "$hour" ] ; then hour="22" ; fi
30     TIME="daily"
31  fi
32
33  COUNT="${4}"
34  case $TIME in
35  daily|hourly|30min|10min|5min) ;;
36        *) echo "ERROR: Invalid frequency specified!" ; exit 5 ;;
37  esac
38  if [ ! $(is_num "$COUNT") ] ; then
39     echo "ERROR: Invalid count specified!" ; exit 5
40  fi
41
42  enable_cron "$DATASET" "$TIME" "$COUNT" "$hour"
43  echo "Snapshot frequency set: $TIME @ $hour"
44  echo "Snapshot # to keep set: $COUNT"
45  exit 0
46fi
47
48if [ "$ACTION" = "stop" ] ; then
49  enable_cron "$DATASET" "OFF"
50  exit 0
51fi
52
Note: See TracBrowser for help on using the repository browser.