Backup CentOS Linux RPM database
Q. How do I backup CentOS Linux server RPM database?
A. /var/lib/rpm directory stores all files used by rpm command. All files inside this directory are binary files. It has the information about all installed package. You can easily backup all files using following method.
Backup Linux RPM Database stored at /var/lib/rpm directory
a) Login as the root user.
b) First remove any stale lock file, enter:
/bin/rm -f /var/lib/rpm/__db*
c) The next step is to back up the /var/lib/rpm directory, using tar command:
# tar czvf $(hostname).rpmdatabase.tar.gz /var/lib/rpm
If your hostname is linux-server, it will save backup to a file called linux-server.rpmdatabase.tar.gz