4 # Script to mirror Ceph locally
6 # Please, choose a local source and do not sync in a shorter interval than
11 # All available source mirrors
13 SOURCES[eu]="eu.ceph.com"
14 SOURCES[de]="de.ceph.com"
15 SOURCES[se]="se.ceph.com"
16 SOURCES[cz]="cz.ceph.com"
17 SOURCES[au]="au.ceph.com"
18 SOURCES[us]="download.ceph.com"
19 SOURCES[hk]="hk.ceph.com"
20 SOURCES[fr]="fr.ceph.com"
21 SOURCES[us-east]="us-east.ceph.com"
22 SOURCES[us-west]="us-west.ceph.com"
23 SOURCES[global]="download.ceph.com"
25 function print_usage() {
26 echo "$0 [-q ] -s <source mirror> -t <target directory>"
29 while getopts ":qhs:t:" opt; do
50 if [ ! -z "$HELP" ] || [ -z "$TARGET" ] || [ -z "$SOURCE" ]; then
55 if [ ! -d "$TARGET" ]; then
56 echo "$TARGET is not a valid target directory"
60 for i in "${!SOURCES[@]}"; do
61 if [ "$i" == "$SOURCE" ]; then
62 SOURCE_HOST=${SOURCES[$i]}
66 if [ -z "$SOURCE_HOST" ]; then
67 echo -n "Please select one of the following sources:"
68 for i in "${!SOURCES[@]}"; do
75 RSYNC_OPTS="--stats --progress"
76 if [ $SILENT -eq 1 ]; then
80 # We start a two-stage sync here for DEB and RPM
81 # Based on: https://www.debian.org/mirror/ftpmirror
83 # The idea is to prevent temporary situations where metadata points to files
87 # Exclude all metadata files
88 rsync ${RSYNC_OPTS} ${SOURCE_HOST}::ceph --recursive --times --links \
96 --exclude repodata/* \
99 # Now also transfer the metadata and delete afterwards
100 rsync ${RSYNC_OPTS} ${SOURCE_HOST}::ceph --recursive --times --links \
101 --hard-links --delete-after \