[CentOS] one-shot yum command to match rpms between systems?

Wed May 18 18:55:51 UTC 2016
m.roth at 5-cent.us <m.roth at 5-cent.us>

Frank Cox wrote:
> On Wed, 18 May 2016 09:30:54 +0100
> James Hogarth wrote:
>> And of course as will be pointed out by many the only right answer is
>> yum
>> update anyway given cherry picking updates is not supported.
> The objective is not to cherry pick updates, but rather to install a
> second system with packages that match the first system.  After
> fine-tuning the installed packages and stripping out the unnecessary
> stuff, it would be nice to just say "make that system look like this one"
> -- rsync for yum if you will.  The specific package versions aren't
> important at that stage since I can run yum update after the initial
> installation.
Two solutions, both of which we use here at work.

1. rpm -qa > file; minimal on new machine, and yum -y install $(cat file).
2. a) on new machine, mkdir /new /boot/new
   b) from old machine,
           sync -HPavzx --exclude=/old --exclude=/var/log/wtmp
--exclude=/var/log/lastlog $newmachine:/. /new/.
           rsync -HPavzx $machine:/boot/. /boot/new/.

   c) then:
rsync -HPavzx /etc/sysconfig/network-scripts/ifcfg-eth*
rsync -HPavzx /etc/sysconfig/hwconf /new/etc/sysconfig
rsync -HPavzx /boot/grub/device.map /boot/new/grub/
rsync -HPavzx /etc/udev/rules.d/70-persistent-net.rules
rsync -HPavzx /etc/ssh/ssh_host* /new/etc/ssh

   d) zsh
zmodload zsh/files

cd /boot
mkdir old
mv * old
mv old/lost+found .
mv old/new/* .

# Root partition.
cd /
mkdir old
mv * old
mv old/lost+found .
mv old/root
mv old/new/* .
And reboot.