Changeset 4e5cced


Ignore:
Timestamp:
Aug 5, 2013 11:45:24 AM (11 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
4f9718b
Parents:
e674d0b
Message:

Add some initial replication framework

Location:
src-sh/lpreserver
Files:
2 edited

Legend:

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

    r8c2bd1a r4e5cced  
    1414if [ ! -d "$DBDIR" ] ; then mkdir -p ${DBDIR} ; fi 
    1515CMDLOG="${DBDIR}/lp-lastcmdout" 
     16REPCONF="${DBDIR}/replication" 
    1617LOGDIR="/var/log" 
    17 export DBDIR LOGDIR PROGDIR CMDLOG 
     18export DBDIR LOGDIR PROGDIR CMDLOG REPCONF 
    1819 
    1920MSGQUEUE="" 
     
    150151  echo -e "$MSGQUEUE" 
    151152} 
     153 
     154add_rep_task() { 
     155  # add freenas.8343 backupuser 22 tank1/usr/home/kris tankbackup/backups sync 
     156  HOST=$1 
     157  USER=$2 
     158  PORT=$3 
     159  LDATA=$4 
     160  RDATA=$5 
     161  TIME=$6 
     162 
     163  case $TIME in 
     164     [0-9][0-9]|sync)  ;; 
     165     *) exit_err "Invalid time: $TIME" 
     166  esac 
     167  
     168  echo "Adding replication task for local dataset $LDATA" 
     169  echo "----------------------------------------------------------" 
     170  echo "   Remote Host: $HOST"  
     171  echo "   Remote User: $USER"  
     172  echo "   Remote Port: $PORT"  
     173  echo "Remote Dataset: $RDATA"  
     174  echo "          Time: $TIME"  
     175  echo "----------------------------------------------------------" 
     176  echo "Don't forget to ensure that this user / dataset exists on the remote host" 
     177  echo "with the correct permissions!" 
     178 
     179  rem_rep_task "$LDATA" 
     180  echo "$LDATA:$TIME:$HOST:$USER:$PORT:$RDATA" >> ${REPCONF} 
     181 
     182} 
     183 
     184rem_rep_task() { 
     185  if [ ! -e "$REPCONF" ] ; then return ; fi 
     186  cat ${REPCONF} | grep -v "^${1}:" > ${REPCONF}.tmp 
     187  mv ${REPCONF}.tmp ${REPCONF} 
     188} 
     189 
  • src-sh/lpreserver/lpreserver

    r1fd551d r4e5cced  
    8989Remove Options: 
    9090 
    91         remove <id> 
     91        remove <dataset> 
    9292         
    93         Remove a replication task indicated by <id> 
     93        Remove a replication task indicated by <dataset> 
    9494        Use 'replicate list' for a list of IDs.  
    9595 
     
    371371         ${PROGDIR}/backend/zfsrmsnap.sh "${DATASET}" "${SNAP}" 
    372372         ;; 
    373  
     373 replicate) require_root 
     374            shift 
     375            case ${1} in 
     376                add) add_rep_task "$2" "$3" "$4" "$5" "$6" "$7" ;; 
     377                list) ;; 
     378                remove) cat ${REPCONF} | grep -q "^${2}:"  
     379                        if [ $? -eq 0 ] ; then 
     380                           rem_rep_task "$2" 
     381                           echo "Removed replication task for $2" 
     382                        else 
     383                           exit_err "No such replication task for dataset $2" 
     384                        fi 
     385                        ;; 
     386                *) exit_err "Invalid option!" ;; 
     387            esac 
     388         ;; 
    374389   *) help_main ;; 
    375390esac 
Note: See TracChangeset for help on using the changeset viewer.