This is an old revision of the document!


[root@ls-xxxx01 wikibackup]# cat push-ro-to-remotesite.sh #!/bin/bash

#based on pushtozz.sh, written Andrew Stringer 11 August 2011 #Purpose is to push wiki to remote sites #modified 12/09/2012 to push to remote sites based on text file.

#This script uses rsync over ssh, so the scope ssh key needs adding to #the nnnn account authorised hosts file to allow passwordless logins.

#turn on debugging, -x starts, +x stops set +x

#set to 3 for testing, this forces sending mail, normally should be 0 SENDEMAIL=0

EMAIL=“me@mydomain.com”

WIKILOCATION=/home/scope/wikibackup/backup

REMOTESITES=/home/scope/wikibackup/remotesitelist.txt

TMPLOG=/tmp/pushwikitoremotesites.txt-$$ DATE=`date +%b“ ”%d“ ”%Y` DAY=`date +%a`

DATENUM=`date +%d` #Test to force 1st of the month #DATENUM=01 if [ $DATENUM == 01 ] then

      MONTHTEST=" - 1st of the month test email."
      SENDEMAIL=2

fi

for REMOTESERVER in `cat ${REMOTESITES}` do

      echo "Push Wiki to remote site" > ${TMPLOG}
      echo "========================" >> ${TMPLOG}
      echo "" >> ${TMPLOG}
      echo "From /home/scope/wikibackup/push-ro-to-remotesite.sh on ls-xxxx" >> ${TMPLOG}
      echo "" >> ${TMPLOG};
      echo "" >> ${TMPLOG};
      OUTPUT=`rsync -a --progress  -e ssh ${WIKILOCATION}/* wworks@${REMOTESERVER}:/home/wworks/wiki-stagingarea/webroot >> ${TMPLOG} `
      RESULT=$?
      echo " " >> ${TMPLOG}
      echo "rsync Returncode is >${RESULT}<" >> ${TMPLOG}
      echo " " >> ${TMPLOG}
      echo "Rsync Output is >${OUTPUT}<" >> ${TMPLOG}
      if [ ${RESULT} != 0 ]
              then
              echo "Wiki push to ${REMOTESERVER} may not have completed, return code was not 0, ( >${RESULT}< ). " >> ${TMPLOG}
              echo "Command returned \"${OUTPUT}\" " >> ${TMPLOG}
              SENDEMAIL=1
      fi
      #Send mail
      if [ ${SENDEMAIL} -eq 1 ]
              then
              /bin/mailx -s "Wiki Push Problems (${REMOTESERVER}).${MONTHTEST}" ${EMAIL} < ${TMPLOG}
      elif [ ${SENDEMAIL} -eq 2 ]
              then
              /bin/mailx -s "Wiki push (${REMOTESERVER}), ${MONTHTEST}." ${EMAIL} < ${TMPLOG}
      elif [ ${SENDEMAIL} -eq 3 ]
              then
              /bin/mailx -s "Wiki push (${REMOTESERVER}), set to testing." ${EMAIL} < ${TMPLOG}
      else
              echo "No errors" > /dev/null
      fi

done

rm $TMPLOG exit 0

[root@ls-xxxx wikibackup]#


rb/copywiki.1367504834.txt.gz · Last modified: 10/10/2013 15:21 (external edit)