Skip to content

Instantly share code, notes, and snippets.

@keithchambers
Last active July 10, 2022 20:06
Show Gist options
  • Save keithchambers/f159cfa84124d527485c to your computer and use it in GitHub Desktop.
Save keithchambers/f159cfa84124d527485c to your computer and use it in GitHub Desktop.
Yum remo mirror with snapshots
#!/bin/bash -ex
URL="$1"
LABEL="$2"
BASEDIR="/vagrant/mirror"
MIRRORDIR="${BASEDIR}/${LABEL}"
SNAPSHOTDIR="${MIRRORDIR}/$(date +%Y%m%d)"
if [[ $(command -v grinder >/dev/null 2>&1) -ne 0 ]]
then
echo "Error: grinder command was not found."
exit 1
fi
mkdir -p ${BASEDIR}
grinder yum --debug \
--parallel 10 \
--url ${URL} \
--label ${LABEL} \
--basepath ${BASEDIR}
[[ -d ${SNAPSHOTDIR} ]] && SNAPSHOTDIR="${SNAPSHOTDIR}-$(date +%H%M%S)"
mkdir -p ${SNAPSHOTDIR}
PKGS=$(find ${MIRRORDIR} -type f \( -name "*.rpm" -o -name "*.srpm" \) -print)
for PKG in ${PKGS}
do
ln -s ${PKG} ${SNAPSHOTDIR}/$(basename ${PKG})
done
cp -r ${MIRRORDIR}/repodata ${SNAPSHOTDIR}
echo "Completed in ${SECONDS} seconds."
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment