Skip to content

Mirroring Repositories with Reposync

Reposync uses DNF/YUM to mirror repositories, which is useful when you want to maintain a local copy of CIQ repositories using standard Linux package management tools.

Prerequisites

  • DNF or YUM installed on your system (standard on RHEL/Rocky Linux)
  • The dnf-utils or yum-utils package installed
  • Your username and access token from https://portal.ciq.com/token
  • Sufficient disk space for the repositories you want to mirror

Install required tools:

sudo dnf install dnf-utils

Setting Up a Repository Configuration

Create a repository configuration file for the CIQ repository you want to mirror.

Finding Repository Information

  1. Log in to https://portal.ciq.com
  2. Navigate to My Products and select a product
  3. Select the repository you want to mirror
  4. View the DNF Config for the repository URL

Creating the Configuration

Create a file in /etc/yum.repos.d/ (e.g., /etc/yum.repos.d/ciq-mirror.repo):

[ciq-mirror-repo]
name=CIQ Repository Mirror Source
baseurl=https://depot.ciq.com/path/to/repo
username=YOUR_USERNAME
password=YOUR_TOKEN
enabled=0
gpgcheck=1

Replace YOUR_USERNAME and YOUR_TOKEN with credentials from portal.ciq.com/token.

Enabled=0

Setting enabled=0 prevents this repository from being used for regular package installations. It will only be used when explicitly referenced by reposync.

File Permissions

This file contains your access token. Restrict permissions:

sudo chmod 600 /etc/yum.repos.d/ciq-mirror.repo

Running Reposync

Basic Mirror

sudo dnf reposync \
  --repoid=ciq-mirror-repo \
  --download-metadata \
  -p /var/www/html/repos/

With Newest Packages Only

To download only the latest version of each package (saves space):

sudo dnf reposync \
  --repoid=ciq-mirror-repo \
  --download-metadata \
  --newest-only \
  -p /var/www/html/repos/

Delete Removed Packages

To remove local packages that are no longer in the upstream repository:

sudo dnf reposync \
  --repoid=ciq-mirror-repo \
  --download-metadata \
  --delete \
  -p /var/www/html/repos/

Scheduling Regular Syncs

Create a Sync Script

Create /usr/local/bin/reposync-ciq.sh:

#!/bin/bash
# Mirror CIQ repositories using reposync

LOG_FILE="/var/log/reposync-ciq.log"

echo "=== Reposync started at $(date) ===" >> "$LOG_FILE"

dnf reposync \
  --repoid=ciq-mirror-repo \
  --download-metadata \
  --delete \
  -p /var/www/html/repos/ >> "$LOG_FILE" 2>&1

if [ $? -eq 0 ]; then
    echo "=== Reposync completed successfully at $(date) ===" >> "$LOG_FILE"
else
    echo "=== Reposync failed at $(date) ===" >> "$LOG_FILE"
fi
sudo chmod +x /usr/local/bin/reposync-ciq.sh

Schedule with Cron

sudo crontab -e
# Daily at 3 AM
0 3 * * * /usr/local/bin/reposync-ciq.sh

Serving the Local Mirror

Configure client systems to use your local mirror:

[local-ciq-repo]
name=Local CIQ Repository Mirror
baseurl=http://your-mirror-server/repos/ciq-mirror-repo/
enabled=1
gpgcheck=1

Troubleshooting

Authentication Failures

Problem: Reposync fails with 401 or 403 errors.

Solutions:

  • Verify credentials in the repository configuration file
  • Check that the token hasn't been regenerated
  • Test credentials manually:
    curl -u 'YOUR_USERNAME:YOUR_TOKEN' https://depot.ciq.com/path/to/repo/repodata/repomd.xml
    

Metadata Download Failures

Problem: Repository metadata download fails.

Solutions:

  • Verify the repository URL is correct
  • Ensure --download-metadata flag is included
  • Check network connectivity to depot.ciq.com
  • Try clearing the DNF cache: dnf clean all

Disk Space Issues

Problem: Reposync fails due to insufficient space.

Solutions:

  • Check available space: df -h /var/www/html/repos
  • Use --newest-only to reduce space requirements
  • Monitor repository growth over time

See Also