Difference between revisions of "Mirror rsync setup"

From CSLabsWiki
(remove code tag)
(Add impl)
 
Line 33: Line 33:
 
fi
 
fi
 
</pre>
 
</pre>
  +
  +
As mirroradmin:
  +
cp /etc/mirrorscripts/generic.sh /etc/mirrorscripts/newname.sh
  +
add entry to crontab -e
  +
As root:
  +
mkdir /storage/newname
  +
chown mirroradmin:mirroradmin /storage/newname

Latest revision as of 16:07, 19 April 2014

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

#!/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

As mirroradmin:

cp /etc/mirrorscripts/generic.sh /etc/mirrorscripts/newname.sh
add entry to crontab -e

As root:

mkdir /storage/newname
chown mirroradmin:mirroradmin /storage/newname