Restore old /etc onto newer system (CentOS)

Troels Folke asked:

In order to save space, I don’t backup /usr (except /usr/local), /bin, /sbin and /lib. Instead I do a rpm -qa --qf '%{NAME}\n' to get a list of packages I need to install to restore the content of these directories.

When doing a bare-metal recovery, after installing a minimal CentOS system, I install the packages in the list with yum.

Next step is to restore /etc, but here there is a problem: The packages I have just installed may be a newer version than those who were present on my old system when I created the backup. Thus, copying over my old /etc could break things, if configuration formats meanwhile has changed, or make my installation less secure, if important configuration directives has been added in the meantime. Checking every single configuration file is an option, but I would rather avoid it. Could it be done in a more automated fashion?

My answer:

Run rpm -Vac. You will get a list of every configuration file installed by RPM which has been altered.

Also, if you restore the contents of /etc before installing the packages, then yum will notice, and place any configuration files that are different with a .rpmnew extension. You can then go and look at those files individually.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.