Results 1 to 6 of 6
Lets say I have a Red hat server, and I want to make a copy of it. The most obvious way to do this would be to make a clone. ...
- 03-30-2010 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 13
RPM query - New server
Lets say I have a Red hat server, and I want to make a copy of it. The most obvious way to do this would be to make a clone. If we assume I can't do this, and I want to be able to build the server from scratch, and bring it up to the same level, then what would be the best way to achieve this?
I know you can do a rpm -qa to find out a list of rpms. My problem is though that over time rpms will have been installed, or maybe even removed. It seems very time consuming to get a list and to manually find all the rpms. The redhat network lists which software is installed, but there is no way to download all of the rpms at once.
I suppose this is a task ideally addressed by the red hat satellite service but sadly I don't have this option. A local yum repository would be good, but of course I would need a way to find all the rpms i need. I don't understand why you can't just select rpms and download them all from the rhn.
Just wondered if anyone had any ideas.
- 03-31-2010 #2
You could save the list of rpm names from the existing box:
This will give you two files:Code:rpm -qa --queryformat "%{NAME}\n" |sort|uniq|tee sorted_uniq_rpmlist | xargs echo > sorted_uniq_oneline_rpmlist
sorted_uniq_rpmlist and sorted_uniq_oneline_rpmlist
The list is sorted for better diffing against the package list of the second system
and it is uniq´ed to filter out possible double names because of arch (i386 and x86_64).
You can then use sorted_uniq_oneline_rpmlist to install the same packages on the second machine.
Probably yum will bark as the list of argument can get very long.Code:yum install `cat sorted_uniq_oneline_rpmlist`
In that case a loop might help:
Of course, the second machine needs access to rhn (aka it needs a valid subscription) to be able to use yum.Code:for PACKAGE in `cat sorted_uniq_oneline_rpmlist`; do yum install $PACKAGE; done
After either of the two yum installs finished, you can run on the second machine
Do a diff of sorted_uniq_rpmlist and sorted_uniq_rpmlist-2 to verify, that the second machine has now the same packages.Code:rpm -qa --queryformat "%{NAME}\n" |sort|uniq > sorted_uniq_rpmlist-2
This procedure should give you an installation with the same packages.You must always face the curtain with a bow.
- 03-31-2010 #3
One more thing:
This will only work for RPMs that can be installed via yum, aka: that are in reachable and configured repositories.
On a default install of a subscriped redhat this is the rhn only, but one could imagine additional repositories.
All manual installed RPMs that you might have, will have to be manually installed on the second machine as well.You must always face the curtain with a bow.
- 04-06-2010 #4Just Joined!
- Join Date
- Nov 2009
- Posts
- 13
Thank you for that, it's very helpful

I was just wondering though, if you could modify that so it only shows the rpms installed after a particular date? Is there a way to do this?
- 04-08-2010 #5Just Joined!
- Join Date
- Nov 2009
- Posts
- 13
Just one more question. I've noticed that the packages listed, do not state the version number. Is there a way to state this? On this particular server I am working on it has a lot of old packages, so don't want to be installing the latest ones.
- 04-08-2010 #6
Sure there is.
Search the man page of rpm for QUERYFMT
and modify the example I have given earlierYou must always face the curtain with a bow.


Reply With Quote