blob: 88197b6ec365729400cfaa818fb2a170762db2d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/bash
# mirror-sync.sh
# Sync multiple mirrors with ZFS-friendly logging and checkpoints
set -o pipefail
set +e # don’t stop the whole script on a non-zero exit
LOG_DIR="/var/log/mirror-sync"
mkdir -p "$LOG_DIR"
MIRROR_ROOT="/brimstone2/mirror"
MIRROR_ROOT2="/brimstone1/mirror"
# Timestamp helper
ts() {
date +"[%Y-%m-%d %H:%M:%S]"
}
sync_mirror() {
local name="$1"
local url="$2"
local path="$3"
local logfile="$LOG_DIR/${name}.log"
echo "===================================================" | tee -a "$logfile"
echo "$(ts) Starting $name sync..." | tee -a "$logfile"
echo "===================================================" | tee -a "$logfile"
rsync -avhr --delete "$url" "$path" >> "$logfile" 2>&1
local status=$?
if [[ $status -eq 0 ]]; then
echo "$(ts) $name mirror sync finished successfully." | tee -a "$logfile"
else
echo "$(ts) WARNING: $name mirror sync exited with status $status." | tee -a "$logfile"
fi
}
# Mirrors
sync_mirror "gentoo" "rsync://masterdistfiles.gentoo.org/gentoo/" "$MIRROR_ROOT/gentoo/"
sync_mirror "hbsd" "rsync://rsync.hardenedbsd.org/all/" "$MIRROR_ROOT/hardenedbsd/"
sync_mirror "slackware" "rsync://mirrors.kernel.org/slackware/" "$MIRROR_ROOT/slackware/"
sync_mirror "void" "rsync://mirrors.servercentral.com/voidlinux/" "$MIRROR_ROOT2/void"
|