summaryrefslogtreecommitdiff
path: root/mirror-sync.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mirror-sync.sh')
-rwxr-xr-xmirror-sync.sh43
1 files changed, 43 insertions, 0 deletions
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"