Last active
November 26, 2021 09:24
-
-
Save xenithorb/1fc54297e930eb71b31e8d48f25db8d2 to your computer and use it in GitHub Desktop.
Script for rsyncing fedora repos for local private mirror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION=24 | |
ARCH="x86_64" | |
REPO_DIR=/media/backup/repos/fedora/linux/ | |
MIRROR=( | |
"rsync://repo.atlantic.net/fedora/linux/" | |
"rsync://mirror.lstn.net/fedora-enchilada/" | |
) | |
REPORT_MIRROR_PATH="/root/mirrormanager2/client/report_mirror" | |
for ((i=0; i<${#MIRROR[@]}; i++)); do | |
rsync --progress -amH --numeric-ids --delete --delete-delay --delay-updates \ | |
--exclude='*/drpms' \ | |
--exclude='*/images' \ | |
--exclude='*/Docker' \ | |
--exclude='*/CloudImages' \ | |
--exclude='*/debug' \ | |
--exclude='*/iso' \ | |
--include="**/${VERSION}/**${ARCH}/***" \ | |
--include='*/' --exclude='*' \ | |
"${MIRROR[i]}" "${REPO_DIR}" | |
(( rsync_exit_status=$? )) | |
done | |
find "${REPO_DIR}" -name "*comps-*.xml" -exec sh -c 'cp -av {} "$(dirname {})/../comps.xml"' \; | |
for i in $(find "${REPO_DIR}" -type d -name 'repodata' -exec dirname '{}' \;); do | |
# createrepo -v --update -g comps.xml "$i" | |
(( createrepo_exit_status+=$? )) | |
done | |
pre_exit_status=$(( createrepo_exit_status + rsync_exit_status )) | |
if (( pre_exit_status == 0 )); then | |
"${REPORT_MIRROR_PATH}" && exit 0 || exit $(( pre_exit_status + $? )) | |
else | |
exit $pre_exit_status | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment