Mirror rsync setup

From CSLabsWiki
Revision as of 15:37, 19 April 2014 by Meshca (talk | contribs) (add tags)

All of the scripts that rsync content from other mirrors to our mirror live in /etc/mirrorscripts. The user mirrroradmin owns and runs all of the scripts here. It also owns /storage. Mirroradmin runs the scripts through cron. The log files end up in /var/log/rsync/ and the lock files in /var/lock/rsync.

Template: /etc/mirrorscripts/generic.sh

<code>
#!/bin/bash

data=
data_location=
mirror=

source /etc/mirrorscripts/globalvars

if [ ! -e ${lockfile} ]
then
  ${TOUCH} ${lockfile}

  if [ ! -d ${data_location} ]; then
    ${MKDIR} ${data_location}
  fi

  echo "Sync started on $(${DATE})." >> ${logfile}

  ${RSYNC} ${options} ${mirror}::${data} ${data_location} >> ${logfile}

  ${RM} ${lockfile}

  exit 0
else
  echo "Sync already running on $(${DATE})." >> ${errorlogfile}
  
  exit 1
fi
</code>