Changeset 95978b1


Ignore:
Timestamp:
09/18/14 14:09:23 (3 months ago)
Author:
Bjarne Bertilsson <bjarne.bertilsson@…>
Branches:
master, releng/10.1
Children:
1d2d08cc
Parents:
d139132
Message:

Add scheduled scrub within lifepreserver

Location:
src-sh/lpreserver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-sh/lpreserver/backend/functions.sh

    r54d2124 r95978b1  
    110110} 
    111111 
    112 enable_cron() 
     112enable_cron_snap() 
    113113{ 
    114114   cronscript="${PROGDIR}/backend/runsnap.sh" 
     
    131131 
    132132   echo -e "$cLine\troot    ${cronscript} $1 $3" >> /etc/crontab 
     133} 
     134 
     135enable_cron_scrub() 
     136{ 
     137   cronscript="${PROGDIR}/backend/runscrub.sh" 
     138 
     139   # Make sure we remove any old entries for this dataset 
     140   cat /etc/crontab | grep -v " $cronscript $1" > /etc/crontab.new 
     141   mv /etc/crontab.new /etc/crontab 
     142   if [ "$2" = "OFF" ] ; then 
     143      return  
     144   fi 
     145 
     146   case $2 in 
     147       daily) cLine="0       $3      *       *       *" ;; 
     148       weekly) cLine="0       $4      *       *       $3" ;; 
     149       monthly) cLine="0       $4      $3       *       *" ;; 
     150           *) exit_err "Invalid time specified" ;; 
     151   esac  
     152 
     153   echo -e "$cLine\troot    ${cronscript} $1" >> /etc/crontab 
    133154} 
    134155 
  • src-sh/lpreserver/backend/zfscronsnap.sh

    r9cd0fa0 r95978b1  
    2424 
    2525  if [ "$TIME" = "auto" ] ; then 
    26      enable_cron "$DATASET" "auto" "auto" "auto" 
     26     enable_cron_snap "$DATASET" "auto" "auto" "auto" 
    2727     echo "Snapshot frequency set: Automatic" 
    2828     exit 0 
     
    4646  fi 
    4747 
    48   enable_cron "$DATASET" "$TIME" "$COUNT" "$hour" 
     48  enable_cron_snap "$DATASET" "$TIME" "$COUNT" "$hour" 
    4949  echo "Snapshot frequency set: $TIME @ $hour" 
    5050  echo "Snapshot # to keep set: $COUNT" 
     
    5353 
    5454if [ "$ACTION" = "stop" ] ; then 
    55   enable_cron "$DATASET" "OFF" 
     55  enable_cron_snap "$DATASET" "OFF" 
    5656  exit 0 
    5757fi 
  • src-sh/lpreserver/lpreserver

    r2a42e58 r95978b1  
    4343 
    4444   cronsnap - Schedule snapshot creation via cron 
     45  cronscrub - Schedule scrub via cron 
    4546        get - Get list of lpreserver options 
    4647   listcron - Listing of scheduled snapshots 
     
    361362}; 
    362363 
     364help_cronscrub() 
     365{ 
     366 title 
     367 echo "Help cronscrub 
     368 
     369Schedule a ZFS scrub 
     370 
     371Usage: 
     372 
     373  To start / stop scrub scheduling 
     374 
     375  # lpreserver cronscrub <dataset> <action> <frequency> 
     376   
     377  action = start / stop 
     378  frequency = daily@XX / weekly@YY@XX / monthly@ZZ@XX 
     379      XX = Hour to execute, YY = Day of week to execute, ZZ = Day of month 
     380 
     381  NOTE:  
     382     
     383    If 'daily' is given without hour the default is 22. 
     384    If 'weekly' is given without day or hour the default is day 1 and hour 22. 
     385    (1 = Mon, 7 = Sun) 
     386    If 'monthly' is given without day or hour the default is day 1 and hour 22. 
     387 
     388Example: 
     389 
     390  lpreserver cronscrub tank1 start daily@22 
     391  (run scrub everyday at 10 AM) 
     392 
     393  or 
     394 
     395  lpreserver cronscrub tank1 start weekly@5@5 
     396  (run scrub every Friday at 5 PM) 
     397 
     398  or 
     399 
     400  lpreserver cronscrub tank1 start monthly@21@13 
     401  (run scrub on the 21:st every month at 1 AM) 
     402 
     403  or 
     404 
     405  lpreserver cronscrub tank1 stop 
     406" 
     407}; 
     408 
    363409help_revertsnap() 
    364410{ 
     
    476522           replicate) help_replicate ;; 
    477523           cronsnap) help_cronsnap ;; 
     524           cronscrub) help_cronscrub ;; 
    478525           rmsnap) help_rmsnap ;; 
    479526           status) help_status ;; 
     
    537584         DATASET="$2" 
    538585         ${PROGDIR}/backend/zfscronsnap.sh "${DATASET}" "$3" "$4" "$5" 
     586         ;; 
     587 
     588cronscrub) require_root 
     589         DATASET="$2" 
     590         ${PROGDIR}/backend/zfscronscrub.sh "${DATASET}" "$3" "$4" 
    539591         ;; 
    540592 
Note: See TracChangeset for help on using the changeset viewer.