CentOS-logo

CentOS-logo

Intro.

  • Say you have an old crufty CentOS host that you cannot absolutely touch because it is workingtm (apart from the occasional apache-OOM, that is).
  • Say you are required to migrate this old system to a new hardware (perhaps to a VM), and, for the occasion, to a more recent CentOS version.

Fortunately with Linux, you have plenty of options!

One of them could be by manually cloning the old CentOS configuation to the new one (essentially by trying to replicate the existing setup on the new system).

But how to clone the installed programs list to the new one? It can be done!

On the Old CentOS host:

Launch (on the old system):

rpm -qa --queryformat “%{NAME}\n” > yum.packages.list

This command will export the list of the applications installed on the old CentOS without the architecture extension, version number, revision, etc. (ie: "gnome-utils-libs" vs "gnome-utils-libs-2.28.3-1.fc11.i586").

Much better, but the real advantage of the previous command is that it will create a list of packages compatible to yum (ie.: this packages list could be directly supplied to the yum command)!

On the New CentOS host.

This way you could:

yum -y install < yum-packages.list

And yum will simply fetch and install the latest versions of the packages specified on the list file directly from its repos. Please note that, before launching the previous command, I'd recommend you to at least check the repos (on both systems).

Now you can focus on the serious stuff: the /etc folder and the configuration files. Good luck!

SRC:

http://www.cyberciti.biz/tips/linux-get-list-installed-software-reinstallation-restore.html

Rate this post

4 comments on “Clone installed packages between different CentOS versions.

  • Thank you very much!

    Turns out that thet format on Fedora 20 is slightly different:

    rpm -qa --queryformat “%{NAME}”\\n > yum.packages.list

  • In addition, keeping Wilbert's correction in mind as well, the above command for installing the packages on the new host is incorrect. The filename was not typed exactly as created on the old system.
    Correction below:

    yum -y install < yum.packages.list

    • In fact, the command didn't work for my on CentOS 6.5.

      The reason why this didn't work was for two reasons:
      1. because the command had the wrong double quotes that are pretty printed here.

      rpm -qa --queryformat "%{NAME}"\\n > yum.packages.list

      2. the yum install command didn't accept the file's contents properly. so I used cat instead with the following command:

      yum -y install $(cat yum.packages.list)

      There were some packages that didn't show up as available in the initial install process listing, but the dependencies resolving in the install process fixed it at the end.

  • The above quotes won't print out correctly in the comments .. so make sure that you use universal double quotes (not left double quote and right double quotes)

Comments are closed.