/etc and /usr/local/etc backup restore strategy

Hi,

I have several questions that revolve around the same subject, so actually an answer could solve multiple questions.
I imagine some of you do this regularly, so I would like to benefit from your experience.
Case 1:
I backup /etc and /usr/local/etc on FreeBSD X RELEASE , and then I install on the same machine the same version, FreeBSD X RELEASE. Is it ok if I just replace the newly created /etc and /usr/local/etc and restore the ones in backup ?

Case 2:
Similar to Case 1, but with a minor version higher, so for example from 9.0-RELEASE (backed up version) to 9.1-RELEASE the newly installed version.

Or is it better to copy the backed-up etcs over the fresh ones, or the other way around, or use some merge program ?

Another question: if I keep updating my system (say using portmaster or pkg upgrade), what happens with my customized /etc files in case the upgrade would change also the respective configuration files ?

The last one: is it /usr/local/etc used for having configuration files that override the ones in /etc ? or it contains just a different set of configuration files, that is for /usr applications ?

Of course, my intention is to make things easier in the future, and the final objective to fully automate the configuration of FreeBSD, using a tool like Cfengine3.
But first, I have to understand how the configuration files work and how they evolve from one version to another.

Thank you!
 
Case 1 does not make sense. Why would you reinstall the same version?

Case 2 is just an upgrade. No, you should not just restore a backup of /etc over the new files. Some may have actually changed. mergemaster(8) is the tool that is meant to be used to merge user changes with system changes. But that's for source upgrades. Actually, source upgrades are easier than a reinstall, so consider them. There's also freebsd-update(8), which deals with binary upgrades.

/usr/local/etc is where added applications like ports and packages keep their configuration settings. These should not affect system settings in /etc.
 
Thank you for your answer. So then /etc contents is very specific depending on the version of FreeBSD, on the options chosen during install, on the machine, and on further configurations or updates of the system. But then why I do hear often "backup your /etc" ?

So I'm thinking then the right solution is to keep whatever configurations/customizations in a script of some sort that applies then the customizations on the fresh system.

For example, I will always need, say, this options in /etc/rc.conf in my desktop configuration:

Code:
hald_enable="YES"
dbus_enable="YES"
kdm4_enable="YES"

If I reinstall FreeBSD on my laptop, or if I buy a new laptop and reinstall, I want to have them.


I needed Case 1 recently on my laptop to switch from UFS to ZFS. I would need Case 1 if I need to automate the installation of a server...just to apply it on other machines.

Thank you!
 
choosy23 said:
Thank you for your answer. So then /etc contents is very specific depending on the version of FreeBSD, on the options chosen during install, on the machine, and on further configurations or updates of the system. But then why I do hear often "backup your /etc" ?

There are several things in /etc. Some are user-configured settings. But there are also the rc scripts, for instance, which change from release to release. In fact, they change fairly frequently on the -STABLE branches. If you just copy all of an old /etc over the new version, the old scripts will overwrite the current ones.

So I'm thinking then the right solution is to keep whatever configurations/customizations in a script of some sort that applies then the customizations on the fresh system.

That would work. When setting up a new system, I often have a copy of the old /etc available to copy and integrate changes. When I change a file in /etc, or /usr/local/etc, or anywhere, really, I put in a comment with my initials. So I can find files that I changed with grep(1).

Some people have much nicer methods, like using devel/subversion. With a revision control system like that, you can even roll back changes, or see what changed previously. And there are automated systems like sysutils/cfengine and sysutils/puppet. It depends on what you need, and how often.

I needed Case 1 recently on my laptop to switch from UFS to ZFS. I would need Case 1 if I need to automate the installation of a server...just to apply it on other machines.

Oh, that makes sense. Another way to do that would be to back up, do a minimal ZFS install, and then restore over that system.
 
Thank you for your answer, wblock@. I now have the solutions to handle this problem from simple to complex. And a better understanding of why /etc should not be blindly replaced with a backed-up one.
 
Back
Top