Clone packages from one system to another (broken dnf and sys python fix)

From vpsget wiki
Jump to: navigation, search

Here we will show how to download installed packages from one Centos/RHE to another Centos\RHE where both server OS version is equal.

On a current example we also show how to fix the broken DNF / yum ... this may happens when you accidentaly installed python from a sources into the system python folder.

Se we have SRV1 - where everything working fine and SRV2 where problem occur and we need to clone the packages from one system to another. Also keep in mind that on SRV2 dnf and yum not working so ou able to use rpm or build from a sources (if you have previously installed Dev Tools with cmake/make)

  • on SRV1:*

Check python packages installed:

rpm -qa | grep python 
rpm -qa | grep dnf

Create dir for rpms:

mkdir /opt/myrpms

Download all installed packages into folder:

cd /opt/myrpms 
rpm -qa | grep python | while read line; do echo $line && yumdownloader --resolve $line; done
rpm -qa | grep dnf | while read line; do echo $line && yumdownloader --resolve $line; done

!Keep an eye to output: if you will note that some packages were not downloaded /missed. SO better to run yum update first!

Copy folder with downloaded rpms to your SRV2

scp -r /opt/myrpms  $SRV2_IP:/opt/
  • on SRV2:*

You may first check and count packages like:

rpm -qa| grep python | wc -l && cd /opt/myrpms && ls -la | grep python | wc -l 

Remove all python related and dnf packages:

 rpm -qa | grep python |while read app; do echo $app && rpm -e --nodeps $app; done
 rpm -qa | grep dnf |while read app; do echo $app && rpm -e --nodeps $app; done

Now go to a myrpms dir that we've uploaded from SRB1 and install all with --nodeps param

cd /opt/myrpms
rpm -Uvh --nodeps *

For any case check that packages were installed:

rpm -qa | grep python && rpm -qa | grep dnf

That's all we've clonned the exact custom rpms bundle from one server to another and restored dnf [also yum will start working as it depend on dnf //centos8]

run

dnf 
#:)