From 13eb2d51c7284472efabc278bf9b7ec0b8575e47 Mon Sep 17 00:00:00 2001 From: doc Date: Sun, 14 Sep 2025 22:13:41 +0000 Subject: first commit --- mirror-sync.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 mirror-sync.sh (limited to 'mirror-sync.sh') diff --git a/mirror-sync.sh b/mirror-sync.sh new file mode 100755 index 0000000..88197b6 --- /dev/null +++ b/mirror-sync.sh @@ -0,0 +1,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" -- cgit v1.2.3