This is another one of those reminders to myself that reposync on Oracle Linux 8 has the ability to sync all packages and metadata and it’s installed by default in the oraclelinux:8 container image. Combined those two pieces of knowledge and you get a quick and easy yum repo mirroring solution.

The updated version of reposync that ships in all EL8-based distributions has some new options that make it possible to sync a multiple repos without needing to manually configure them beforehand, all in a single command.

Here’s a sample command:

reposync --repo=ol7_UEKR4 \
  --repofrompath=ol7_UEKR4, \
  --delete \
  --download-metadata \
  --download-path /repos \

Let’s look at those parameters in more detail, shall we?

  • --repo limits reposync to a single repo instead of trying to sync all the repos currently enabled for the host. It’s different to the more widely known --enablerepo parameter in that it enables only the specified repo. It’s a shorthand for --disablerepo=* --enablerepo=blah. It can be specified multiple times.
  • --repofrompath takes a value of [repoid,path] where repoid is what would usually be between the [] in a .repo file and path is any value baseurl value for yum or dnf, including both http and file paths. What’s even more delightful is that it can also be specified multiple times.
  • --delete will delete packages and metadata that have been removed upstream. This is important in the (very rare) instances where we have to pull a released package. You don’t want that left on your mirror.
  • --download-metadata is where the real magic happens. It downloads the contents of the repodata metadata from the host so that the output folder is both automatically and immediately available as a yum repository locally. It also downloads all the modularity metadata for dnf. And all the errata information!
  • --remote-time tries to set the timestamps of local files to match those on the server.

Combine all that with the container engine of your choice and you can create a single (albeit quite long) command to sync all the content you want. Here’s an example that uses a Docker container to download the base repos required for both Oracle Linux 7 and 8 to the /repos folder on the host:

docker run --rm -it -v /repos:/repos oraclelinux:8 \
  reposync  --delete --download-metadata --remote-time \
  --download-path=/repos \
  --repo=ol7_latest --repofrompath=ol7_latest, \
  --repo=ol7_optional_latest --repofrompath=ol7_optional_latest, \
  --repo=ol7_UEKR6 --repofrompath=ol7_UEKR6, \
  --repo=ol8_baseos_latest --repofrompath=ol8_baseos_latest, \
  --repo=ol8_appstream --repofrompath=ol8_appstream, \
  --repo=ol8_UEKR6 --repofrompath=ol8_UEKR6,

At some point I’ll probably create a container image that automates this completely, but this will do for now.