[CentOS-mirror] mirror.bytemark.co.uk

Alex Howells alex at bytemark.co.uk
Mon Jan 14 14:01:35 UTC 2008


> You can use CentOS master server bellow to sync your mirror:
> 
> eu-msync.centos.org::CentOS [EU users may wish to use]

We're using this one now, seems relatively nippy.  We've been mirroring
from either Belnet or HEAnet in the past; they're both pretty good.

#!/usr/bin/ruby
def xsys(c); exit $? unless system(c); end

RSYNC = ENV['RSYNC']
RSYNC_MODULES = %w( CentOS )
RSYNC_HOST = "rsync://eu-msync.centos.org"
RSYNC_DIR = ENV['MIRRORDIR']

options = []
options += %w(
  --exclude='.~tmp~/'
  --exclude='alpha/'
  --exclude='ia64/'
  --exclude='s390/'
  --exclude='s390x/'
  --exclude='isos/'
  --exclude='isos-dvd/'
  --exclude '*.iso'
)

RSYNC_MODULES.each do |mod|
  cmdline = [RSYNC]
  cmdline += options
  cmdline << "#{RSYNC_HOST}/#{mod}"
  cmdline << "#{RSYNC_DIR}/centos"
  puts cmdline.join(" ")
  xsys("mkdir -p #{cmdline[-1]}")
  xsys(cmdline.join(" "))
end

# Pass 2
RSYNC_MODULES.each do |mod|
  cmdline = [RSYNC]
  cmdline += options
  cmdline += %w(
    --delete
    --delete-after
    --delete-excluded
  )
  cmdline << "#{RSYNC_HOST}/#{mod}"
  cmdline << "#{RSYNC_DIR}/centos"
  p cmdline.join(" ")
  xsys(cmdline.join(" "))
end

Two-way mirror approach ensures that old content is only deleted after
the fresh RPMs have been sync'd into the mirror.

It's invoked by a simple wrapper script through cron.

#!/bin/bash
LIST=$*
cd /mirror/scripts/sites

export MIRRORDIR="/mirror/public"
export RSYNC="rsync --verbose --partial --progress --recursive --perms
--times --links --safe-links --sparse --bwlimit=5120 --address=80.68.87.200"

for SCRIPT in $LIST ; do
        ./$SCRIPT
done

I'm sure it's not perfect, but it does the trick :)   Works especially
well for things like Debian / Ubuntu, and you can handle
distribution-specific things like architecture excludes using loops.
Saves writing out a *huge* rsync command and maintaining it.

Alex



More information about the CentOS-mirror mailing list