Replicate RPM's to another server

php Aug 31, 2017

Something that makes part of our day..replicate some RPM's to another server for easy 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

Transfer to the new server

Now that we have that file on the new server, let's install all the RPM with a single command:

yum install -y $(cat /tmp/php-rpms)