Scripts
|
Size: 1473
Comment:
|
← Revision 20 as of 2025-09-19 14:32:48 ⇥
Size: 3420
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| '''Work in Progress!''' | #refresh 0 https://canonical-ubuntu-project.readthedocs-hosted.com/release-team/mirror-scripts/ |
| Line 3: | Line 3: |
| ||<tablestyle="float:right; width:30%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;">'''Contents'''|| ||<<TableOfContents(2)>>|| To be able to create a mirror people can rely on, you need to have all the files and you need them at the right moment. 'File not found'-errors cause a lot of issues and annoyances for users. This page provides you with scripts to sync from other mirrors and prevent 404's. |
|
| Line 4: | Line 7: |
| To be able to create a mirror people can rely on, you need to have all the files and you need them at the right moment. 'File not found'-errors cause a lot of issues and annoyances for users. This page provides you with scripts to sync from other mirrors and prevent 404's. | = ubumirror = One can use the scripts from the '''[[https://code.launchpad.net/~ubumirror-devs/ubumirror/trunk|ubumirror]]''' project to keep their mirror in sync, or use the scripts provided below. This project has been [[https://launchpad.net/ubuntu/+source/ubumirror|packaged since Lucid]] onwards, please file any bug reports you find [[https://bugs.launchpad.net/ubuntu/+source/ubumirror|against it]]. |
| Line 20: | Line 27: |
| warn() { echo "$1" } |
|
| Line 22: | Line 33: |
| # rsync://archive.ubuntu.com/ubuntu should always work RSYNCSOURCE=rsync://archive.ubuntu.com/ubuntu |
# rsync://<iso-country-code>.rsync.archive.ubuntu.com/ubuntu should always work RSYNCSOURCE=rsync://archive.ubuntu.mirror.isp.com/ubuntu |
| Line 27: | Line 38: |
| rsync --recursive --times --links --hard-links \ | if [ ! -d ${BASEDIR} ]; then warn "${BASEDIR} does not exist yet, trying to create it..." mkdir -p ${BASEDIR} || fatal "Creation of ${BASEDIR} failed." fi rsync --recursive --times --links --safe-links --hard-links \ |
| Line 30: | Line 47: |
| --exclude "Release*" \ ${RSYNCSOURCE} ${BASEDIR} || fatal "First stage of sync failed" |
--exclude "Release*" --exclude "InRelease" \ ${RSYNCSOURCE} ${BASEDIR} || fatal "First stage of sync failed." |
| Line 33: | Line 50: |
| rsync --recursive --times --links --hard-links \ | rsync --recursive --times --links --safe-links --hard-links \ |
| Line 35: | Line 52: |
| ${RSYNCSOURCE} ${BASEDIR} || fatal "Second stage of sync failed" | ${RSYNCSOURCE} ${BASEDIR} || fatal "Second stage of sync failed." date -u > ${BASEDIR}/project/trace/$(hostname -f) |
| Line 39: | Line 58: |
For Releases mirrors, stuff is a little less complicated. There are no dependencies between files, so you can just rsync away. == The script == {{{ #/bin/dash fatal() { echo "$1" exit 1 } warn() { echo "$1" } # Find a source mirror near you which supports rsync on # https://launchpad.net/ubuntu/+cdmirrors # rsync://<iso-country-code>.rsync.releases.ubuntu.com/releases should always work RSYNCSOURCE=rsync://releases.ubuntu.mirror.isp.com/releases # Define where you want the mirror-data to be on your mirror BASEDIR=/var/www/ubuntureleases/ if [ ! -d ${BASEDIR} ]; then warn "${BASEDIR} does not exist yet, trying to create it..." mkdir -p ${BASEDIR} || fatal "Creation of ${BASEDIR} failed." fi rsync --verbose --recursive --times --links --safe-links --hard-links \ --stats --delete-after \ ${RSYNCSOURCE} ${BASEDIR} || fatal "Failed to rsync from ${RSYNCSOURCE}." date -u > ${BASEDIR}/.trace/$(hostname -f) }}} |
Contents |
To be able to create a mirror people can rely on, you need to have all the files and you need them at the right moment. 'File not found'-errors cause a lot of issues and annoyances for users. This page provides you with scripts to sync from other mirrors and prevent 404's.
ubumirror
One can use the scripts from the ubumirror project to keep their mirror in sync, or use the scripts provided below.
This project has been packaged since Lucid onwards, please file any bug reports you find against it.
Archive mirrors
For archive mirrors, it is very important not to delete packages before the Packages.gz-files (which hold information about the packages available) are updated. Therefor, you need a 'Two stage sync'. This means that you download new packages first, and new Packages.gz after that. After you've downloaded the Packages.gz files, it's safe to delete old packages.
The script
#/bin/dash
fatal() {
echo "$1"
exit 1
}
warn() {
echo "$1"
}
# Find a source mirror near you which supports rsync on
# https://launchpad.net/ubuntu/+archivemirrors
# rsync://<iso-country-code>.rsync.archive.ubuntu.com/ubuntu should always work
RSYNCSOURCE=rsync://archive.ubuntu.mirror.isp.com/ubuntu
# Define where you want the mirror-data to be on your mirror
BASEDIR=/var/www/ubuntuarchive/
if [ ! -d ${BASEDIR} ]; then
warn "${BASEDIR} does not exist yet, trying to create it..."
mkdir -p ${BASEDIR} || fatal "Creation of ${BASEDIR} failed."
fi
rsync --recursive --times --links --safe-links --hard-links \
--stats \
--exclude "Packages*" --exclude "Sources*" \
--exclude "Release*" --exclude "InRelease" \
${RSYNCSOURCE} ${BASEDIR} || fatal "First stage of sync failed."
rsync --recursive --times --links --safe-links --hard-links \
--stats --delete --delete-after \
${RSYNCSOURCE} ${BASEDIR} || fatal "Second stage of sync failed."
date -u > ${BASEDIR}/project/trace/$(hostname -f)
Releases mirrors
For Releases mirrors, stuff is a little less complicated. There are no dependencies between files, so you can just rsync away.
The script
#/bin/dash
fatal() {
echo "$1"
exit 1
}
warn() {
echo "$1"
}
# Find a source mirror near you which supports rsync on
# https://launchpad.net/ubuntu/+cdmirrors
# rsync://<iso-country-code>.rsync.releases.ubuntu.com/releases should always work
RSYNCSOURCE=rsync://releases.ubuntu.mirror.isp.com/releases
# Define where you want the mirror-data to be on your mirror
BASEDIR=/var/www/ubuntureleases/
if [ ! -d ${BASEDIR} ]; then
warn "${BASEDIR} does not exist yet, trying to create it..."
mkdir -p ${BASEDIR} || fatal "Creation of ${BASEDIR} failed."
fi
rsync --verbose --recursive --times --links --safe-links --hard-links \
--stats --delete-after \
${RSYNCSOURCE} ${BASEDIR} || fatal "Failed to rsync from ${RSYNCSOURCE}."
date -u > ${BASEDIR}/.trace/$(hostname -f)Mirrors/Scripts (last edited 2025-09-19 14:32:48 by sally-makin)