2019-05-29 19:03:44 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# (c) 2019 Red Hat, Inc.
|
|
|
|
# LGPL
|
|
|
|
# Author: Rick Elrod <relrod@redhat.com>
|
|
|
|
|
|
|
|
if [[ "$1" == "" ]] || [[ $1 != /pub* ]] || [[ $1 != */ ]]; then
|
|
|
|
echo "Syntax: $0 /pub/path/to/sync/"
|
|
|
|
echo "NOTE! Path must end with a trailing /"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-10 20:03:15 +00:00
|
|
|
# first run do not delete anything or copy the repodata.
|
|
|
|
CMD1="aws s3 sync \
|
|
|
|
--exclude */repodata/* \
|
|
|
|
--exclude *.snapshot/* \
|
|
|
|
--exclude *source/* \
|
|
|
|
--exclude *SRPMS/* \
|
|
|
|
--exclude *debug/* \
|
|
|
|
--exclude *beta/* \
|
|
|
|
--exclude *ppc/* \
|
|
|
|
--exclude *ppc64/* \
|
|
|
|
--exclude *repoview/* \
|
|
|
|
--exclude *Fedora/* \
|
|
|
|
--exclude *EFI/* \
|
|
|
|
--exclude *core/* \
|
|
|
|
--exclude *extras/* \
|
|
|
|
--exclude *LiveOS/* \
|
|
|
|
--exclude *development/rawhide/* \
|
|
|
|
--no-follow-symlinks \
|
|
|
|
--only-show-errors \
|
|
|
|
"
|
|
|
|
#--dryrun \
|
|
|
|
|
|
|
|
# second we delete old content and also copy the repodata
|
|
|
|
CMD2="aws s3 sync \
|
2019-05-29 19:03:44 +00:00
|
|
|
--delete \
|
2019-05-29 22:28:18 +00:00
|
|
|
--exclude *.snapshot/* \
|
|
|
|
--exclude *source/* \
|
|
|
|
--exclude *SRPMS/* \
|
|
|
|
--exclude *debug/* \
|
|
|
|
--exclude *beta/* \
|
|
|
|
--exclude *ppc/* \
|
|
|
|
--exclude *ppc64/* \
|
|
|
|
--exclude *repoview/* \
|
|
|
|
--exclude *Fedora/* \
|
|
|
|
--exclude *EFI/* \
|
|
|
|
--exclude *core/* \
|
|
|
|
--exclude *extras/* \
|
|
|
|
--exclude *LiveOS/* \
|
2019-08-21 18:15:47 +00:00
|
|
|
--exclude *development/rawhide/* \
|
2019-05-30 15:51:03 +00:00
|
|
|
--no-follow-symlinks \
|
|
|
|
--only-show-errors \
|
2019-05-29 19:03:44 +00:00
|
|
|
"
|
|
|
|
#--dryrun \
|
|
|
|
|
2019-09-23 21:17:10 +00:00
|
|
|
#echo "$CMD /srv$1 s3://s3-mirror-us-west-1-02.fedoraproject.org$1"
|
2019-05-29 19:03:44 +00:00
|
|
|
echo "Starting $1 sync at $(date)" >> /var/log/s3-mirror/timestamps
|
2020-03-10 20:03:15 +00:00
|
|
|
$CMD1 /srv$1 s3://s3-mirror-us-west-1-02.fedoraproject.org$1
|
|
|
|
$CMD1 /srv$1/repodata/ s3://s3-mirror-us-west-1-02.fedoraproject.org$1/repodata/
|
2019-05-29 19:03:44 +00:00
|
|
|
# Always do the invalidations because they are quick and prevent issues
|
|
|
|
# depending on which path is synced.
|
2020-03-10 20:03:15 +00:00
|
|
|
for file in $(echo $1/repodata/* ); do
|
2019-05-31 15:28:04 +00:00
|
|
|
aws cloudfront create-invalidation --distribution-id E2KJMDC0QAJDMU --paths "$file" > /dev/null
|
2019-05-29 19:03:44 +00:00
|
|
|
done
|
2020-03-10 20:03:15 +00:00
|
|
|
$CMD2 /srv$1 s3://s3-mirror-us-west-1-02.fedoraproject.org$1
|
|
|
|
echo "Ending $1 sync at $(date)" >> /var/log/s3-mirror/timestamps
|