Ignore:
Timestamp:
Sep 12, 2013 7:08:56 AM (7 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
03c14f8
Parents:
651bd28
Message:

Update to lpreserver backend:

Added new "replicate init <dataset>" option, which will re-init the remote side of the replication server, cleaning up any corrupt datasets and preparing to sync fresh again.

Also added a check during replication, we won't try to kickoff a second replication task if a previous one is still running, to avoid collisions. In addition we will not delete any snapshots until the initial replication is finished, in order to prevent undercutting the active replication

File:
1 edited

Legend:

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

    rac48c86 rc0e6494  
    1818fi 
    1919 
     20# Make sure this is a valid DATASET 
     21zfs list ${DATASET} >/dev/null 2>/dev/null 
     22if [ $? -ne 0 ] ; then 
     23   exit_err "Invalid dataset specified ${DATASET}" 
     24fi 
     25 
    2026# Create the snapshot now with the "auto-" tag 
    2127echo_log "Creating snapshot on ${DATASET}" 
     
    2329if [ $? -ne 0 ] ; then 
    2430  echo_log "ERROR: Failed creating snapshot on ${DATASET}" 
    25   queue_msg "Snapshot ERROR" "ERROR: Failed creating snapshot on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
     31  queue_msg "ERROR: Failed creating snapshot on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
    2632  snapStat=1 
    2733else 
     
    3844done 
    3945 
    40 # Do any pruning 
    41 num=0 
    42 for snap in $rSnaps 
    43 do 
    44    # Only remove snapshots which are auto-created, so we don't delete one the user 
    45    # made specifically 
    46    cur="`echo $snap | cut -d '-' -f 1`"  
    47    if [ "$cur" != "auto" ] ; then 
    48      continue; 
    49    fi 
     46# Before we start pruning, check if any replication is running 
     47skipPrune=0 
     48export pidFile="${DBDIR}/.reptask-`echo ${DATASET} | sed 's|/|-|g'`" 
     49if [ -e "${pidFile}" ] ; then 
     50   pgrep -F ${pidFile} >/dev/null 2>/dev/null 
     51   if [ $? -eq 0 ] ; then skipPrune=1; fi 
     52fi 
    5053 
    51    num=`expr $num + 1` 
    52    if [ $num -gt $KEEP ] ; then 
    53       echo_log "Pruning old snapshot: $snap" 
    54       rmZFSSnap "${DATASET}" "$snap" 
    55       if [ $? -ne 0 ] ; then 
    56         echo_log "ERROR: Failed pruning snapshot $snap on ${DATASET}" 
    57         queue_msg "Snapshot ERROR" "ERROR: Failed pruning snapshot $snap on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
    58         snapStat=1 
    59       else 
    60         queue_msg "Success pruning snapshot $snap on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
     54if [ $skipPrune -eq 1 ] ; then 
     55  # No pruning since replication is currently running 
     56  echo_log "WARNING: Skipped pruning snapshots on ${DATASET} while replication is running." 
     57  queue_msg "WARNING: Skipped pruning snapshots on ${DATASET} while replication is running." 
     58 
     59else 
     60  # Do any pruning 
     61  num=0 
     62  for snap in $rSnaps 
     63  do 
     64     # Only remove snapshots which are auto-created, so we don't delete one the user 
     65     # made specifically 
     66     cur="`echo $snap | cut -d '-' -f 1`"  
     67     if [ "$cur" != "auto" ] ; then 
     68       continue; 
     69     fi 
     70 
     71     num=`expr $num + 1` 
     72     if [ $num -gt $KEEP ] ; then 
     73        echo_log "Pruning old snapshot: $snap" 
     74        rmZFSSnap "${DATASET}" "$snap" 
     75        if [ $? -ne 0 ] ; then 
     76          echo_log "ERROR: Failed pruning snapshot $snap on ${DATASET}" 
     77          queue_msg "ERROR: Failed pruning snapshot $snap on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
     78          snapStat=1 
     79        else 
     80          queue_msg "Success pruning snapshot $snap on ${DATASET} @ `date`\n\r`cat $CMDLOG`" 
     81        fi 
    6182      fi 
    62     fi 
    63 done 
     83  done 
     84fi 
    6485 
    6586# If we failed at any point, sent out a notice 
Note: See TracChangeset for help on using the changeset viewer.