Ignore:
Timestamp:
08/08/13 11:58:30 (13 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
04b42e5
Parents:
13dd2f6
Message:

Add ability to save a dataset properties during replication, this will allow
us to re-create / import data from a replicated dataset to a new system / disk.

File:
1 edited

Legend:

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

    rf615958 rf6cd78a  
    242242  if [ "$2" = "sync" -a "$TIME" = "sync" ] ; then 
    243243     export DIDREP=1 
    244      echo_log "`date`: Starting replication SYNC task on ${DATASET}\n" 
     244     echo_log "`date`: Starting replication SYNC task on ${DATASET}" 
    245245     queue_msg "`date`: Starting replication SYNC task on ${DATASET}\n" 
    246246     start_rep_task "$LDATA" 
     
    249249     # Ready to do a scheduled replication 
    250250     export DIDREP=1 
    251      echo_log "`date`: Starting replication SCHEDULED task on ${DATASET}\n" 
     251     echo_log "`date`: Starting replication SCHEDULED task on ${DATASET}" 
    252252     queue_msg "`date`: Starting replication SCHEDULED task on ${DATASET}\n" 
    253253     start_rep_task "$LDATA" 
     
    293293     zfs set backup:lpreserver=' ' ${LDATA}@$lastSEND 
    294294     zfs set backup:lpreserver=LATEST ${LDATA}@$lastSNAP 
    295      echo_log "`date`: Finished replication task on ${DATASET}\n" 
     295     echo_log "`date`: Finished replication task on ${DATASET}" 
     296     save_rep_props 
     297     zStatus=$? 
    296298  else 
    297299     # FAILED :-( 
     
    303305     echo "\nRecv log:\n" >> ${FLOG} 
    304306     cat ${CMDLOG2} >> ${FLOG} 
    305      echo_log "`date`: FAILED replication task on ${DATASET}: LOGFILE: $FLOG\n" 
     307     echo_log "`date`: FAILED replication task on ${DATASET}: LOGFILE: $FLOG" 
    306308  fi 
    307309 
     
    309311} 
    310312 
    311 get_data_props() { 
     313save_rep_props() { 
     314  # If we are not doing a recursive backup / complete dataset we can skip this 
     315  if [ "$RECURMODE" != "ON" ] ; then return 0; fi 
     316  if [ "`basename $DATASET`" != "$DATASET" ] ; then return 0; fi 
     317 
     318  echo_log "`date`: Saving dataset properties for: ${DATASET}" 
     319  queue_msg "`date`: Saving dataset properties for: ${DATASET}\n" 
    312320 
    313321  # Lets start by building a list of props to keep 
    314   pTag=`echo $DATASET | md5` 
    315  
    316   if [ "$RECURMODE" = "ON" ] ; then 
    317      zfs get -r all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
    318   else 
    319      zfs get all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " > /tmp/.propList.$$ 
    320   fi 
    321   
    322   cat /tmp/.propList.$$ 
    323   rm /tmp/.propList.$$ 
    324  
    325 } 
     322  rProp=".lp-repset`echo ${REPRDATA} | sed 's|/|#|g'`" 
     323 
     324  zfs get -r all $DATASET | grep ' local$' | awk '{$1=$1}1' OFS=" " | sed 's| local$||g' \ 
     325        | ssh -p ${REPPORT} ${REPUSER}@${REPHOST} "cat > $rProp" 
     326  if [ $? -eq 0 ] ; then 
     327    echo_log "`date`: Successful save of dataset properties for: ${DATASET}" 
     328    queue_msg "`date`: Successful save of dataset properties for: ${DATASET}\n" 
     329    return 0 
     330  else 
     331    echo_log "`date`: Failed saving dataset properties for: ${DATASET}" 
     332    queue_msg "`date`: Failed saving dataset properties for: ${DATASET}\n" 
     333    return 1 
     334  fi 
     335} 
Note: See TracChangeset for help on using the changeset viewer.