Backup CentOS Linux RPM database

last updated in Categories , , ,

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):