In the last days I had a problem with a crashed virtual disk on a WebSphere Application Server. The backup team was able to recover all the data, but the operating system needs to be reinstalled. The operating system was Red Hat Linux, so rpm-based. One of the first tasks after recovery was to identify and reinstall missing packages.
A big advantage was that several WebSphere nodes were used in this environment, the Deployment Manager was still intact, and a still working server could be used as a basis for determining the missing packages.
I used the following commands:
rpm -qa | sort > all-packages-node1.txt
rpm -qa | sort > all-packages-restored.txt
Now we need to compare the lists and generate a list of all missing packages:
comm -23 all-packages-node1.txt all-packages-restored.txt > missing-packages.txt
So we have a list of missing packages, in this case I had to install about 200 packages. I’m a little lazy and didn’t want to enter or copy and paste all the package names. So let’s use a short bash snippet (not very elegant, but it works):
while read $i; do sudo yum -y install $i done < missing-packages.txt
The installation process takes a few minutes, but after that all missing packages should be reinstalled. If additional repositories are needed, they should be reactivated or added before the installation process. Manually installed RPM packages can be found by repeating the above procedure and checking for missing packages.
I also used these snippets when I changed my working machine. So I created a backup list of all installed applications and reinstalled everything on the new computer.
I now regularly create the list of installed packages so that it can be stored on the backup tapes and used during recovery.