]> git.proxmox.com Git - ceph.git/blame - ceph/mirroring/mirror-ceph.sh
update ceph source to reef 18.1.2
[ceph.git] / ceph / mirroring / mirror-ceph.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2set -e
3#
4# Script to mirror Ceph locally
5#
6# Please, choose a local source and do not sync in a shorter interval than
7# 3 hours.
8#
9SILENT=0
10
11# All available source mirrors
12declare -A SOURCES
13SOURCES[eu]="eu.ceph.com"
14SOURCES[de]="de.ceph.com"
15SOURCES[se]="se.ceph.com"
7c673cae
FG
16SOURCES[au]="au.ceph.com"
17SOURCES[us]="download.ceph.com"
7c673cae 18SOURCES[fr]="fr.ceph.com"
20effc67 19SOURCES[ca]="ca.ceph.com"
7c673cae
FG
20SOURCES[us-west]="us-west.ceph.com"
21SOURCES[global]="download.ceph.com"
22
23function print_usage() {
24 echo "$0 [-q ] -s <source mirror> -t <target directory>"
25}
26
27while getopts ":qhs:t:" opt; do
28 case $opt in
29 q)
30 SILENT=1
31 ;;
32 s)
33 SOURCE=$OPTARG
34 ;;
35 t)
36 TARGET=$OPTARG
37 ;;
38 h)
39 HELP=1
40 ;;
41 \?)
42 print_usage
43 exit 1
44 ;;
45 esac
46done
47
48if [ ! -z "$HELP" ] || [ -z "$TARGET" ] || [ -z "$SOURCE" ]; then
49 print_usage
50 exit 1
51fi
52
53if [ ! -d "$TARGET" ]; then
54 echo "$TARGET is not a valid target directory"
55 exit 1
56fi
57
58for i in "${!SOURCES[@]}"; do
59 if [ "$i" == "$SOURCE" ]; then
60 SOURCE_HOST=${SOURCES[$i]}
61 fi
62done
63
64if [ -z "$SOURCE_HOST" ]; then
65 echo -n "Please select one of the following sources:"
66 for i in "${!SOURCES[@]}"; do
67 echo -n " $i"
68 done
69 echo ""
70 exit 1
71fi
72
73RSYNC_OPTS="--stats --progress"
74if [ $SILENT -eq 1 ]; then
75 RSYNC_OPTS="--quiet"
76fi
77
78# We start a two-stage sync here for DEB and RPM
79# Based on: https://www.debian.org/mirror/ftpmirror
80#
81# The idea is to prevent temporary situations where metadata points to files
82# which do not exist
83#
84
85# Exclude all metadata files
86rsync ${RSYNC_OPTS} ${SOURCE_HOST}::ceph --recursive --times --links \
87 --hard-links \
88 --exclude Packages* \
89 --exclude Sources* \
90 --exclude Release* \
91 --exclude InRelease \
92 --exclude i18n/* \
93 --exclude ls-lR* \
94 --exclude repodata/* \
95 ${TARGET}
96
97# Now also transfer the metadata and delete afterwards
98rsync ${RSYNC_OPTS} ${SOURCE_HOST}::ceph --recursive --times --links \
99 --hard-links --delete-after \
100 ${TARGET}