Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rb:copywiki [02/05/2013 15:22]
andrew removed
rb:copywiki [02/05/2013 15:33]
andrew
Line 1: Line 1:
-====== Copy Wiki ====== 
  
  
-  [root@server]# cat explodewiki.sh+  [root@ls-xxxx01 wikibackup]# cat  ​push-ro-to-remotesite.sh
   #!/bin/bash   #!/bin/bash
   ​   ​
-  #Written ​Andrew Stringer ​12 August 2011 +  #based on pushtozz.sh,​ written ​Andrew Stringer ​11 August 2011 
-  #This explodes the gzipped tar file of the wiki backup +  #Purpose is to push wiki to remote sites 
-  #and copies the contents ​to the webroot+  #modified 12/​09/​2012 ​to push to remote sites based on text file. 
-  #Additionally it copies an invalid users file over the user +  ​ 
-  #auth file to turn this into a read only copy.+  #This script uses rsync over ssh, so the scope ssh key needs adding to 
 +  #the nnnn account authorised hosts file to allow passwordless logins.
   ​   ​
-  #ls-xxx01 is responsible for pushing this file, /​home/​yyyy/​xxxx/​pushwikitozzz.sh 
   ​   ​
   #turn on debugging, -x starts, +x stops   #turn on debugging, -x starts, +x stops
   set +x   set +x
   ​   ​
-  #set to for testing, this forces sending mail, normally should be 0 +  #set to for testing, this forces sending mail, normally should be 0 
-  ​THRESHOLD=0 +  ​SENDEMAIL=0
-  #​EMAIL=user@xxx.com +
-  EMAIL=andrew.stringer@xxx.com +
-  TARLOCATION=/​home/​zzz/​wiki-stagingarea +
-  ARCHIVE=/​home/​zzz/​wiki-stagingarea/​archive +
-  WEBROOT=/​var/​www/​zzwiki+
   ​   ​
-  ​TMPLOG=/​tmp/​explode.txt-$$ +  ​EMAIL="​me@mydomain.com"
-  DATE=`date +%b" ​"​%d"​ "%Y` +
-  DAY=`date +%a`+
   ​   ​
 +  WIKILOCATION=/​home/​scope/​wikibackup/​backup
   ​   ​
-  ​echo "​Explode Wiki on zzz-ops01"​ > ${TMPLOG} +  ​REMOTESITES=/home/scope/wikibackup/remotesitelist.txt
-  echo "========================="​ >> ${TMPLOG} +
-  echo ""​ >> ${TMPLOG} +
-  echo "​From ​/home/zzzz/wiki-staging/explodewiki.sh on zzz-ops01"​ >> ${TMPLOG} +
-  echo ""​ >> ${TMPLOG};​ +
-  echo ""​ >> ${TMPLOG};+
   ​   ​
-  ​echo "​Starting tar extract." >> ​${TMPLOG}+  ​TMPLOG=/​tmp/​pushwikitoremotesites.txt-$
 +  DATE=`date +%b" "​%d"​ "%Y` 
 +  DAY=`date +%a`
   ​   ​
-  cd /​home/​zzzz/​wiki-stagingarea 
-  #tar -xvzf ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz 
-  DURATION=$(time (tar -xvzf ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz > /dev/null 2>&​1) 2>&​1) 
-  TARRESULT=$?​ 
   ​   ​
 +  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
   ​   ​
-  ​echo "​Explode return code is >${TARRESULT}<,​ it took" >> ${TMPLOG+  ​for REMOTESERVER in `cat ${REMOTESITES}` 
-  ​echo "​${DURATION}"​ >> ${TMPLOG} +  ​do
-  echo "" ​ >> ${TMPLOG}+
   ​   ​
-  #move copy to Archive after untar. +          echo "Push Wiki to remote site" > ${TMPLOG} 
-  ​mv ​${TARLOCATION}/ww-wiki-backup-${DAY}.tar.gz ​$ARCHIVE+          echo "​========================"​ >> ​${TMPLOG} 
 +          echo ""​ >> ${TMPLOG} 
 +          echo "​From ​/home/​scope/​wikibackup/​push-ro-to-remotesite.sh on ls-xxxx" >> ​${TMPLOG} 
 +          echo ""​ >> ​${TMPLOG}; 
 +          echo ""​ >> ${TMPLOG};
   ​   ​
-  #debug only +          OUTPUT=`rsync -a --progress ​ -e ssh ${WIKILOCATION}/wworks@${REMOTESERVER}:​/​home/​wworks/​wiki-stagingarea/​webroot >> ${TMPLOG} ` 
-  #echo "​ls ​-l /home/wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/"​ +          RESULT=$?
-  #ls -l /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/​+
   ​   ​
-  #move backup contents to web server root+          echo " " >> ${TMPLOG} 
 +          echo "rsync Returncode is >​${RESULT}<"​ >> ${TMPLOG} 
 +          echo " " >> ${TMPLOG} 
 +          echo "Rsync Output is >​${OUTPUT}<"​ >> ${TMPLOG}
   ​   ​
-  ​echo "Starting file copy and delete." >> ${TMPLOG} +          if [ ${RESULT} != 0 ] 
-  cp -rv /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/​* ${WEBROOT} +                  then 
-  CPRESULT=$?​ +                  ​echo "Wiki push to ${REMOTESERVER} may not have completed, return code was not 0, ( >​${RESULT}<​ ). " >> ${TMPLOG} 
-  ​echo "Copy Wiki result code is >${CPRESULT}<" >> ${TMPLOG}+                  echo "Command returned \"${OUTPUT}\" ​" >> ${TMPLOG} 
 +                  SENDEMAIL=1 
 +          fi
   ​   ​
-  rm -rf /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/​* 
-  RMRESULT=$? 
-  echo "rm return code is >​${RMRESULT}<"​ >> ${TMPLOG} 
-  echo " " ​ >> ${TMPLOG} 
   ​   ​
 +          #Send mail
 +          if [ ${SENDEMAIL} -eq 1 ]
 +                  then
 +                  /bin/mailx -s "Wiki Push Problems (${REMOTESERVER}).${MONTHTEST}"​ ${EMAIL} < ${TMPLOG}
   ​   ​
-  #Fix permissions in Gib copy to turn it in to a read only copy +          elif [ ${SENDEMAIL-eq 2 ] 
-  echo "​Copying dummy users file over real user" ​ >> ​${TMPLOG+                  ​then 
-  ​cp ​/var/www/​wiki/​users.auth.php /​var/​www/​giwiki/​conf/​users.auth.php +                  ​/bin/mailx -s "Wiki push (${REMOTESERVER}),​ ${MONTHTEST}." ​${EMAIL} < ${TMPLOG}
-  CPUSERRESULT=$?+
   ​   ​
-  echo "User Fix return is >${CPUSERRESULT}<" ​>> ​${TMPLOG} +          elif [ ${SENDEMAIL-eq 3 ] 
-  echo " ​" ​ >> ​${TMPLOG}+                  then 
 +                  /bin/mailx -s "Wiki push (${REMOTESERVER}), set to testing." ​${EMAIL} < ${TMPLOG} 
 +          else
   ​   ​
 +                  echo "No errors"​ > /dev/null
   ​   ​
-  #If any errors encountered,​ send email. +          fi 
-  ​if [ ${TARRESULT} != 0 ] || [ ${CPRESULT} != 0 ] || [ ${RMRESULT} != 0 ] || [ ${CPUSERRESULT} != 0 ] +  ​done
-          then +
-          THRESHOLD=1 +
-  fi+
   ​   ​
-  #Send mail 
-  if [ ${THRESHOLD} -eq 1 ] 
-          then 
-          /bin/mailx -s "GI Wiki extract or copy Problems."​ ${EMAIL} < ${TMPLOG} 
-  fi 
   ​   ​
   ​   ​
 +  rm $TMPLOG
 +  exit 0
   ​   ​
-  ​rm ${TMPLOG} +  ​[root@ls-xxxx wikibackup]#​
-  exit ${THRESHOLD}+
   ​   ​
-  ​ 
- 

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