Create a local mirror of a Percona repository¶
Enterprises introduce various security policies: for example, allow Internet access only on one server or deny root privileges to database administrators.
To comply with these policies and install Percona software in your environment, a solution is to set up the local mirror of Percona repositories. This document provides instructions how to do it.
Important
The instructions below are for AMD/Intel x64 architectures.
Prerequisites¶
To create a local mirror of a Percona repository, you need the following software:
- Rsync to download packages from Percona repositories and upload them to your mirror
 - 
Repository creation tools:
dpkg-devfor Debian and Ubuntucreaterepofor RHEL and derivatives
 
Debian and Ubuntu¶
Run the following commands as the root user or via sudo:
- 
Install
dpkg-devutility to unpack, build and upload Debian source packages.$ sudo apt install dpkg-dev - 
Create the folder where your mirror repository resides. For example,
/opt/debs/$ sudo mkdir -p /opt/debs/ - 
Download the
.debpackages relevant to your operating system from Percona repository into your repository usingrsync:$ sudo rsync -avrt rsync://rsync.percona.com/rsync/<repo-name>/apt/pool/main/p/<product_name>/*.<os-version>*.deb /opt/debs/For example, to download Percona Backup for MongoDB packages on Ubuntu 22.04, the command is the following:
$ sudo rsync -avrt rsync://rsync.percona.com/rsync/pbm/apt/pool/main/p/percona-backup-mongodb/*.jammy*.deb /opt/debs/Check the list of available repositories for MySQL, MongoDB, PostgreSQL and Percona Tools.
 - 
Create the Packages file. This is the file that the package manager uses to retrieve the information about new and updated packages when you run
apt-get update. Use thedpkg-scanpackagescommand:$ cd /opt/debs $ sudo dpkg-scanpackages . /dev/null > PackagesThe command adds the latest version of the packages to the Packages file.
 - 
Import the GPG key to sign the repository.
$ sudo curl -fsSL https://github.com/percona/percona-repositories/raw/main/deb/percona-keyring.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/percona-keyring.gpg >/dev/null - 
Add your repository to the
etc/apt/sources.listfile for the package manager to find new or updated packages from your repository:$ echo "deb [trusted=yes] file:///opt/debs ./" | sudo tee -a /etc/apt/sources.list - 
Run
apt-get updateto check that the package manager can read from your repository. - 
(Optional) Check your mirror repository contents:
$ sudo apt-cache policy percona-backup-mongodbSample output
percona-backup-mongodb: Installed: (none) Candidate: 2.3.1-1.jammy Version table: 2.3.1-1.jammy 500 500 file:/opt/debs ./ Packages 
RHEL and derivatives¶
Run the following commands as the root user or via sudo:
- 
Install the
createrepoutility. It creates yum repositories and their metadata caches$ sudo yum install createrepo - 
Create the directory where your mirror repository resides. For example,
/opt/rpms$ sudo mkdir /opt/rpms - 
Download RPM packages from Percona repository to your local mirror using
rsync:$ sudo rsync -avrt rsync://rsync.percona.com/rsync/<repo_name>/yum/release/<os_version>/RPMS/x86_64/ /opt/rpms/For example, to download packages for Percona Distribution for PostgreSQL 15 on Oracle Linux 9, the command is the following:
$ sudo rsync -avrt rsync://rsync.percona.com/rsync/ppg-15/yum/release/9/RPMS/x86_64/ /opt/rpms/Check the list of available repositories for MySQL, MongoDB, PostgreSQL and Percona Tools.
 - 
Create the repository metadata using
createrepo:$ sudo createrepo --update /opt/rpms - 
Import the GPG key to sign the repository:
$ sudo rpm --import https://raw.githubusercontent.com/percona/percona-repositories/release-1.0-27/rpm/RPM-GPG-KEY-Percona - 
Check that the key has been imported successfully:
$ sudo rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n'Sample output
gpg-pubkey-8507efa5-5b02c2fb gpg(Percona MySQL Development Team (Packaging key) <[email protected]>) - 
Create the repository configuration file. It must meet the following criteria:
- It must be located in 
/etc/yum.repos.d/ - It must have the extension 
.repoto be recognized byyum. 
The following is the example of the configuration file:
/etc/yum.repos.d/percona-local.repo[percona-local] name=Local Percona repository baseurl=file:///opt/rpms/ gpgcheck=1 enabled=1 - It must be located in 
 - 
Check the setup:
$ sudo yum repolistSample output
percona-local Local Percona repository 
Keep the mirror repository up-to-date¶
To update your local mirror, do the following:
- 
Download new packages relevant to your operating system from Percona repository
$ rsync -avrt rsync://rsync.percona.com/rsync/<repo-name>/apt/pool/main/p/<product_name>/*.<os-version>*.deb /opt/debs/ - 
Update the Packages file.
$ cd /opt/debs dpkg-scanpackages . /dev/null > Packages - 
Update the local cache.
$ apt update 
- 
Download new packages from Percona repository
$ rsync -avrt rsync://rsync.percona.com/rsync/<repo_name>/yum/release/<os_version>/RPMS/x86_64/ /opt/rpms/ - 
Update the repository metadata
$ sudo createrepo --update /opt/rpms 
Tip
You can automate the download process by adding the task to crontab.
Based on the blog post How to Create Your Own Repositories for Packages by Evgeniy Patlan