Install All Packages After Restore on RPM-based Linux

by Christoph Stoettner
Read in about 2 min · (words)

Fountain pen and a notebook

Photo by Aaron Burden | Unsplash

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:

On a working node

rpm -qa | sort > all-packages-node1.txt

On the restored machine

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.

Points learned

I now regularly create the list of installed packages so that it can be stored on the backup tapes and used during recovery.

Author
Add a comment
Error
There was an error sending your comment, please try again.
Thank you!
Your comment has been submitted and will be published once it has been approved.

Your email address will not be published. Required fields are marked with *

Suggested Reading
Aaron Burden: Fountain pen and a notebook

Original Description

DC-3 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.

Read in about 8 min
Aaron Burden: Fountain pen and a notebook

Original Description

Much like DC-1, DC-2 is another purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.

Read in about 8 min
Aaron Burden: Fountain pen and a notebook

Original Description

DC-1 is a purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.

It was designed to be a challenge for beginners, but just how easy it is will depend on your skills and knowledge, and your ability to learn.

Read in about 5 min