Product SiteDocumentation Site

8.4. Creating YUM mirrors with reposync

reposync is used to synchronize a remote YUM repository with a local directory using yum to get the packages.
Usage:
reposync [options]
Options:
Options:
  -h, --help            show this help message and exit
  -c CONFIG, --config=CONFIG
                        config file to use (defaults to /etc/yum.conf)
  -a ARCH, --arch=ARCH  act as if running the specified arch (default: current
                        arch, note: does not override $releasever)
  -r REPOID, --repoid=REPOID
                        specify repo ids to query, can be specified multiple
                        times (default is all enabled)
  -e CACHEDIR, --cachedir=CACHEDIR
                        directory in which to store metadata
  -t, --tempcache       Use a temp dir for storing/accessing yum-cache
  -d, --delete          delete local packages no longer present in repository
  -p DESTDIR, --download_path=DESTDIR
                        Path to download packages to: defaults to current dir
  -g, --gpgcheck        Remove packages that fail GPG signature checking after
                        downloading
  -u, --urls            Just list urls of what would be downloaded, don't
                        download
  -n, --newest-only     Download only newest packages per-repo
  -q, --quiet           Output as little as possible
  -l, --plugins         enable yum plugin support
It is trivial to reconstruct the metadata with createrepo from a local directory with the rpms.
Example usage to synchronize the rubyera repository.
$ reposync --repoid=rubyera 
rubyera                                              | 3.2 kB     00:00 ... 
[rubyera: 1     of 14    ] Downloading dhcp_probe-1.3.0-2.fc13.x86_64.rpm
[rubyera: 2     of 14    ] Downloading dhcp_probe-1.3.0-4.fc13.x86_64.rpm
[rubyera: 3     of 14    ] Downloading dhcp_probe-1.3.0-3.fc13.x86_64.rpm
[rubyera: 4     of 14    ] Downloading dhcp_probe-debuginfo-1.3.0-2.fc13.x86_64.rpm
[rubyera: 5     of 14    ] Downloading dhcp_probe-debuginfo-1.3.0-4.fc13.x86_64.rpm
[rubyera: 6     of 14    ] Downloading dhcp_probe-debuginfo-1.3.0-3.fc13.x86_64.rpm
[rubyera: 7     of 14    ] Downloading dhcp_probe-debuginfo-1.3.0-1.fc13.x86_64.rpm
[rubyera: 8     of 14    ] Downloading iptables-1.4.5-1.fc12.x86_64.rpm
[rubyera: 9     of 14    ] Downloading iptables-debuginfo-1.4.5-1.fc12.x86_64.rpm
[rubyera: 10    of 14    ] Downloading iptables-devel-1.4.5-1.fc12.x86_64.rpm
[rubyera: 11    of 14    ] Downloading iptables-ipv6-1.4.5-1.fc12.x86_64.rpm
[rubyera: 12    of 14    ] Downloading passenger-2.2.15-1.fc13.x86_64.rpm
[rubyera: 13    of 14    ] Downloading passenger-debuginfo-2.2.15-1.fc13.x86_64.rpm
[rubyera: 14    of 14    ] Downloading rubygem-pg-0.9.0-1.fc13.x86_64.rpm
If you try to synchronize again, reposync will not download the existing packages saving bandwidth.
$ reposync --repoid=rubyera 
[rubyera: 1     of 14    ] Skipping existing dhcp_probe-1.3.0-2.fc13.x86_64.rpm
[rubyera: 2     of 14    ] Skipping existing dhcp_probe-1.3.0-4.fc13.x86_64.rpm
[rubyera: 3     of 14    ] Skipping existing dhcp_probe-1.3.0-3.fc13.x86_64.rpm
[rubyera: 4     of 14    ] Skipping existing dhcp_probe-debuginfo-1.3.0-2.fc13.x86_64.rpm
[rubyera: 5     of 14    ] Skipping existing dhcp_probe-debuginfo-1.3.0-4.fc13.x86_64.rpm
[rubyera: 6     of 14    ] Skipping existing dhcp_probe-debuginfo-1.3.0-3.fc13.x86_64.rpm
[rubyera: 7     of 14    ] Skipping existing dhcp_probe-debuginfo-1.3.0-1.fc13.x86_64.rpm
[rubyera: 8     of 14    ] Skipping existing iptables-1.4.5-1.fc12.x86_64.rpm
[rubyera: 9     of 14    ] Skipping existing iptables-debuginfo-1.4.5-1.fc12.x86_64.rpm
[rubyera: 10    of 14    ] Skipping existing iptables-devel-1.4.5-1.fc12.x86_64.rpm
[rubyera: 11    of 14    ] Skipping existing iptables-ipv6-1.4.5-1.fc12.x86_64.rpm
[rubyera: 12    of 14    ] Skipping existing passenger-2.2.15-1.fc13.x86_64.rpm
[rubyera: 13    of 14    ] Skipping existing passenger-debuginfo-2.2.15-1.fc13.x86_64.rpm
[rubyera: 14    of 14    ] Skipping existing rubygem-pg-0.9.0-1.fc13.x86_64.rpm
An example use is to create a local mirrorfor the fedora and fedora-updates repositories and them locally. It would be extremely quick to install and upgrade packages in this way. The important thing is to maintain regularly synchronized the local mirror with the master repository running every hour reposync and createrepo. It is important to note that the groups file is not downloaded by reposync. Use wget or curl to download it.
One of the advantages of using reposync instead of such mirrored with rsync, ftp or http, is that reposync benefits from the use of the list of mirrors in the definition of the repository you want to mirror by using yum. In return, when you use rsync, ftp or http, it is dependent on a single master server, and if it fails, it is more difficult to recover from such failure and handle it, while with reposync is totally transparent and simple to handle failures.