diff options
author | Remi Collet <remi@remirepo.net> | 2025-01-22 10:39:22 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2025-01-22 10:39:22 +0100 |
commit | bd8d45aa752098dde805551e860994defb3184d2 (patch) | |
tree | 8eed606b408c194f0fc15eda7a3b5edfeaaeac0a | |
parent | 5496969d6018b02585651ba19caefd9b2988ce38 (diff) |
Improve mirrorsync
- simplify TO BE ADAPTED part
- delete date after failure to ensure sync will be run again
- log success/failure for each tree
-rw-r--r-- | mirrorsync | 40 |
1 files changed, 27 insertions, 13 deletions
@@ -57,16 +57,21 @@ opts=(-avSH --exclude="*.~tmp~" --delete-delay --delay-updates) # A complete list of mirrors can be found at # https://rpms.remirepo.net/ -# Enterprise repo source -src1="rsync://rpms.remirepo.net/enterprise" -# Fedora repo source -src2="rsync://rpms.remirepo.net/fedora" - +##### TO BE ADAPTED TO YOUR CONFIGURATION ##### +# sync from primary mirror only allowed to official mirrors +src="rsync://rpms.remirepo.net" # Your local path. Change to whatever fits your system. +dst=/mnt/RepoSync # $mirrormodule is also used in syslog output. mirrormodule="Remi" -dst1="/mnt/RepoSync/${mirrormodule}/enterprise" -dst2="/mnt/RepoSync/${mirrormodule}/fedora" +##### END OF TO BE ADAPTED ##### + +# Enterprise repo +src1="${src}/enterprise" +dst1="${dst}/${mirrormodule}/enterprise" +# Fedora repo +src2="${src}/fedora" +dst2="${dst}/${mirrormodule}/fedora" datefile="date" lockfile="$0.lockfile" @@ -74,7 +79,7 @@ logfile="$0.log" # Always pull the index.html to ensure the latest. curl/wget would still use same bandiwdth to check if the page changed even # if we aren't going to save a new copy -wget https://rpms.remirepo.net/index.html -O /mnt/RepoSync/${mirrormodule}/index.html +wget https://rpms.remirepo.net/index.html -O ${dst}/${mirrormodule}/index.html >> "$logfile" 2>&1 # Check if the datefile has changed on upstream mirror # and exit cleanly if it is still the same @@ -106,19 +111,28 @@ fi # The actual syncing part printf '%s\n' "$$" > "$lockfile" printf "Started update at %(%c)T\n" -1 >> "$logfile" 2>&1 -logger -t rsync "Updating ${mirrormodule}" - # Sync src1/dst1 if there are changes if [[ -n "$checkresult1" ]]; then - rsync_run "${opts[@]}" "${src1}/" "${dst1}/" >> "$logfile" 2>&1 + logger -t rsync "Updating ${mirrormodule} for ${dst1}" + if rsync_run "${opts[@]}" "${src1}/" "${dst1}/" >> "$logfile" 2>&1; then + logger -t rsync "Succeed updating ${mirrormodule}" + else + logger -t rsync "Failed updating ${mirrormodule} see ${logfile}" + rm -f ${dst1}/${datefile} + fi fi # Sync src2/dst2 if there are changes if [[ -n "$checkresult2" ]]; then - rsync_run "${opts[@]}" "${src2}/" "${dst2}/" >> "$logfile" 2>&1 + logger -t rsync "Updating ${mirrormodule} for ${dst2}" + if rsync_run "${opts[@]}" "${src2}/" "${dst2}/" >> "$logfile" 2>&1; then + logger -t rsync "Succeed updating ${mirrormodule}" + else + logger -t rsync "Failed updating ${mirrormodule} see ${logfile}" + rm -f ${dst1}/${datefile} + fi fi -logger -t rsync "Finished updating ${mirrormodule}" printf "End: %(%c)T\n" -1 >> "$logfile" 2>&1 rm -f "$lockfile" |