Skip to content

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-dev for Debian and Ubuntu
    • createrepo for RHEL and derivatives

Debian and Ubuntu

Run the following commands as the root user or via sudo:

  1. Install dpkg-dev utility to unpack, build and upload Debian source packages.

    $ sudo apt install dpkg-dev
    
  2. Create the folder where your mirror repository resides. For example, /opt/debs/

    $ sudo mkdir -p /opt/debs/
    
  3. Download the .deb packages relevant to your operating system from Percona repository into your repository using rsync:

    $ 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.

  4. 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 the dpkg-scanpackages command:

    $ cd /opt/debs
    $ sudo dpkg-scanpackages . /dev/null > Packages
    

    The command adds the latest version of the packages to the Packages file.

  5. 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
    
  6. Add your repository to the etc/apt/sources.list file 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
    
  7. Run apt-get update to check that the package manager can read from your repository.

  8. (Optional) Check your mirror repository contents:

    $ sudo apt-cache policy percona-backup-mongodb 
    
    Sample 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:

  1. Install the createrepo utility. It creates yum repositories and their metadata caches

    $ sudo yum install createrepo
    
  2. Create the directory where your mirror repository resides. For example, /opt/rpms

    $ sudo mkdir /opt/rpms
    
  3. 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.

  4. Create the repository metadata using createrepo:

    $ sudo createrepo --update /opt/rpms
    
  5. 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
    
  6. 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) <mysql-dev@percona.com>)
    
  7. 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 .repo to be recognized by yum.

    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
    
  8. Check the setup:

    $ sudo yum repolist
    
    Sample output
    percona-local                       Local Percona repository
    

Keep the mirror repository up-to-date

To update your local mirror, do the following:

  1. 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/
    
  2. Update the Packages file.

    $ cd /opt/debs
    dpkg-scanpackages . /dev/null > Packages
    
  3. Update the local cache.

    $ apt update
    
  1. Download new packages from Percona repository

    $ rsync -avrt rsync://rsync.percona.com/rsync/<repo_name>/yum/release/<os_version>/RPMS/x86_64/ /opt/rpms/
    
  2. 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

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services.