Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
That sounds reasonable, but what do I do with the configuration files that has been installed as part of the minimal installation, like /etc/sysctl.conf? –  Troels Folke Sep 1 '13 at 17:49
1  
You've either altered them or you haven't. Either way your own copy of the files is what you want to use, right? –  Michael Hampton Sep 1 '13 at 18:11
    
Yes, but I want all changes made by RPM-maintainers to the files incorporated. And while that will happen for the files that are owned by packages I install after having restored /etc from my backup copy, it will not happen to files owned by packages installed before my /etc restoration. That includes all packages that are part of the centos minimal installation, and thus files such as /etc/sysctl.conf –  Troels Folke Sep 1 '13 at 18:37
    
You can run rpm -Vac to see which of them aren't the same, and then yum reinstall the affected packages, and they'll have the originals dropped in with a .rpmnew extension. Eventually you could probably write a script to automate this, to some extent at least, but that's something I would get paid for... :) –  Michael Hampton Sep 1 '13 at 18:40
    
I just tested by overwriting /etc/named.conf with a completely different file on a test system, and then doing yum reinstall bind. No .rpmnew file is created. –  Troels Folke Sep 1 '13 at 18:48

You might take a look at etckeeper.

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, bazaar or darcs repository. It hooks into [apt, yum] to automatically commit changes made to /etc during package upgrades. It tracks file metadata that git does not normally support, but that is important for /etc, such as the permissions of /etc/shadow.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.