Extract RPMs from a Linux system

rpm -qa > installed_rpms.txt

This will create a .txt list of rpms and their version

sudo dnf download --resolve $(cat installed_rpms.txt)

this will iterate the list and install all the packages

if you run into issues like me, I made a bash to skip any RPMs that are not found online

#!/bin/bash

# Create a directory to store downloaded RPMs
mkdir -p rpms_downloaded
cd rpms_downloaded

# Loop through each package in the list and attempt to download it
for pkg in $(cat ../installed_rpms.txt); do
    sudo dnf download --resolve $pkg || echo "Package $pkg could not be found and was skipped"
done

echo "Download completed. RPMs are stored in the rpms_downloaded directory."

1 Like