Replicate RPM Packages

Output specific installed packages from rpm without version or arch to install on another system (server)

Image from Unsplash

Something that makes part of our day..replicate some RPM's to another server foreasy installation without the version or arch.

Let's get all RPM's to a file:

rpm -qa --qf "%{NAME}\n" > /tmp/all-rpms

But, I just need for PHP (example):

rpm -qa --qf "%{NAME}\n" | grep 'php-' > /tmp/php-rpms

This will output something like this:

# cat /tmp/php-rpms
php-pecl-jsonc
php-process
php-pear
php-mysqlnd
php-pecl-imagick
php-mbstring
php-common
php-pecl-msgpack
php-pecl-igbinary
php-xmlrpc
php-soap
php-pecl-zip
Package per line

Transfer to the new serverNow that we have that file on the new server, let's install all the RPM with asingle command:

yum install -y $(cat /tmp/php-rpms)
Install all packages inside php-rpms file