Differences

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

Link to this comparison view

Next revision
Previous revision
rb:pullbackupcopywiki [02/05/2013 15:33]
andrew created
rb:pullbackupcopywiki [10/10/2013 15:21] (current)
Line 2: Line 2:
  
  
-[root@ls-xxxx wikibackup]#​ cat wikibackup-srv03.sh +  ​[root@ls-xxxx wikibackup]#​ cat wikibackup-srv03.sh 
-#​!/​bin/​bash +  #​!/​bin/​bash 
- +   
-#Written Andrew Stringer 07 February 2011 to backup wiki content from srv01 +  #Written Andrew Stringer 07 February 2011 to backup wiki content from srv01 
-#Modified 20th December to back up from srv02 due to srv01 failing. +  #Modified 20th December to back up from srv02 due to srv01 failing. 
- +   
-#turn on debugging, -x starts, +x stops +  #turn on debugging, -x starts, +x stops 
-set +x +  set +x 
- +   
-#set to 3 for testing, this forces sending mail, normally should be 0 +  #set to 3 for testing, this forces sending mail, normally should be 0 
-SENDEMAIL=0 +  SENDEMAIL=0 
- +   
-EMAIL=me@mydomain.com +  EMAIL=me@mydomain.com 
- +   
-BACKUPLOCATION=/​home/​scope/​wikibackup/​backup +  BACKUPLOCATION=/​home/​scope/​wikibackup/​backup 
-TARLOCATION=/​home/​scope/​wikibackup/​compressed +  TARLOCATION=/​home/​scope/​wikibackup/​compressed 
- +   
-TMPLOG=/​tmp/​wikibackup.txt-$$ +  TMPLOG=/​tmp/​wikibackup.txt-$$ 
-DATE=`date +%b" "​%d"​ "%Y` +  DATE=`date +%b" "​%d"​ "%Y` 
-DAY=`date +%a` +  DAY=`date +%a` 
- +   
- +   
-DATENUM=`date +%d` +  DATENUM=`date +%d` 
-#Test to force 1st of the month +  #Test to force 1st of the month 
-#​DATENUM=01 +  #​DATENUM=01 
-if [ $DATENUM == 01 ] +  if [ $DATENUM == 01 ] 
-then +  then 
-        MONTHTEST="​ - 1st of the month test email."​ +          MONTHTEST="​ - 1st of the month test email."​ 
-        SENDEMAIL=2 +          SENDEMAIL=2 
-fi +  fi 
- +   
-echo "Wiki Backup from srv03 to ls-xxxx01"​ > ${TMPLOG} +  echo "Wiki Backup from srv03 to ls-xxxx01"​ > ${TMPLOG} 
-echo "​==================================="​ >> ${TMPLOG} +  echo "​==================================="​ >> ${TMPLOG} 
-echo ""​ >> ${TMPLOG} +  echo ""​ >> ${TMPLOG} 
-echo "From /​home/​scope/​wikibackup/​wikibackup-srv03.sh on ls-xxxx01"​ >> ${TMPLOG} +  echo "From /​home/​scope/​wikibackup/​wikibackup-srv03.sh on ls-xxxx01"​ >> ${TMPLOG} 
-echo ""​ >> ${TMPLOG} +  echo ""​ >> ${TMPLOG} 
-echo ""​ >> ${TMPLOG} +  echo ""​ >> ${TMPLOG} 
- +   
-OUTPUT=`rsync -a --progress ​ -e ssh scope@srv03.domain.pri:/​data/​webroot/​wiki/​* ${BACKUPLOCATION} >> ${TMPLOG} ` +  OUTPUT=`rsync -a --progress ​ -e ssh scope@srv03.domain.pri:/​data/​webroot/​wiki/​* ${BACKUPLOCATION} >> ${TMPLOG} ` 
-RESULT=$? +  RESULT=$? 
- +   
-echo "​Returncode is >​${RESULT}<"​ >> ${TMPLOG} +  echo "​Returncode is >​${RESULT}<"​ >> ${TMPLOG} 
-echo "​output is >​${OUTPUT}<"​ >> ${TMPLOG} +  echo "​output is >​${OUTPUT}<"​ >> ${TMPLOG} 
- +   
-#cat  ${TMPLOG} +  #cat  ${TMPLOG} 
- +   
- +   
-if [ ${RESULT} != 0 ] +  if [ ${RESULT} != 0 ] 
-        then +          then 
-        echo "Wiki backup may not have completed, return code was not 0, ( >​${RESULT}<​ ). " >> ${TMPLOG} +          echo "Wiki backup may not have completed, return code was not 0, ( >​${RESULT}<​ ). " >> ${TMPLOG} 
-        echo "​Command returned \"​${OUTPUT}\"​ " >> ${TMPLOG} +          echo "​Command returned \"​${OUTPUT}\"​ " >> ${TMPLOG} 
-        SENDEMAIL=1 +          SENDEMAIL=1 
-else +  else 
-        #echo "​\${TARLOCATION} is ${TARLOCATION},​ \${BACKUPLOCATION} is ${BACKUPLOCATION}"​ >> ${TMPLOG} +          #echo "​\${TARLOCATION} is ${TARLOCATION},​ \${BACKUPLOCATION} is ${BACKUPLOCATION}"​ >> ${TMPLOG} 
-        echo "​Starting tar up of files"​ +          echo "​Starting tar up of files"​ 
-        echo "​Adding these files to ww-wiki-backup-${DAY}.tar.gz:​-"​ >> ${TMPLOG} +          echo "​Adding these files to ww-wiki-backup-${DAY}.tar.gz:​-"​ >> ${TMPLOG} 
-        /bin/tar -cvzf ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz -C ${BACKUPLOCATION} . >> ${TMPLOG} +          /bin/tar -cvzf ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz -C ${BACKUPLOCATION} . >> ${TMPLOG} 
- +   
-        #Touch start.txt file to force rsync backup to remote site, +          #Touch start.txt file to force rsync backup to remote site, 
-        #this is to allow timestamping of latest rsync backup +          #this is to allow timestamping of latest rsync backup 
-        touch ${BACKUPLOCATION}/​http/​data/​pages/​start.txt +          touch ${BACKUPLOCATION}/​http/​data/​pages/​start.txt 
- +   
-        #start to push latest backup to remote servers +          #start to push latest backup to remote servers 
-        /​home/​scope/​wikibackup/​push-ro-to-remotesite.sh +          /​home/​scope/​wikibackup/​push-ro-to-remotesite.sh 
-        PUSHRESULT=$?​ +          PUSHRESULT=$?​ 
-fi +  fi 
- +   
-#cat  ${TMPLOG} +  #cat  ${TMPLOG} 
- +   
-echo ""​ +  echo ""​ 
-echo "ls -lrt ${TARLOCATION}" ​ >> ${TMPLOG} +  echo "ls -lrt ${TARLOCATION}" ​ >> ${TMPLOG} 
-ls -lrt ${TARLOCATION} >> ${TMPLOG} +  ls -lrt ${TARLOCATION} >> ${TMPLOG} 
-echo "​------------------------------------------------------------------------"​ >> ${TMPLOG} +  echo "​------------------------------------------------------------------------"​ >> ${TMPLOG} 
- +   
-#Send mail +  #Send mail 
-if [ ${SENDEMAIL} -eq 1 ] +  if [ ${SENDEMAIL} -eq 1 ] 
-        then +          then 
-        /bin/mailx -s "Wiki (wiki.prod) backup Problems."​ ${EMAIL} < ${TMPLOG} +          /bin/mailx -s "Wiki (wiki.prod) backup Problems."​ ${EMAIL} < ${TMPLOG} 
-elif [ ${SENDEMAIL} -eq 2 ] +  elif [ ${SENDEMAIL} -eq 2 ] 
-        then +          then 
-        /bin/mailx -s "Wiki (wiki.prod) ${MONTHTEST}."​ ${EMAIL} < ${TMPLOG} +          /bin/mailx -s "Wiki (wiki.prod) ${MONTHTEST}."​ ${EMAIL} < ${TMPLOG} 
-elif [ ${SENDEMAIL} -eq 3 ] +  elif [ ${SENDEMAIL} -eq 3 ] 
-        then +          then 
-        /bin/mailx -s "Wiki (wiki.prod) set to testing."​ ${EMAIL} < ${TMPLOG} +          /bin/mailx -s "Wiki (wiki.prod) set to testing."​ ${EMAIL} < ${TMPLOG} 
-else +  else 
-        echo "No errors"​ > /dev/null +          echo "No errors"​ > /dev/null 
-fi +  fi 
- +   
- +   
-rm ${TMPLOG} +  rm ${TMPLOG} 
-exit 0 +  exit 0 
- +   
-[root@ls-xxxx01 wikibackup]#​ +  [root@ls-xxxx01 wikibackup]#​ 
 +  

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