Debian - What to do when upgrading packages and a config file has changes?
I'm new to system administration and I'm helping admin a server for a student group. I was wondering, what is the best practice for when you're upgrading packages and a config file has changes. I've been looking at the differences and then usually just leaving the old version unless it looks like there is something important to add, and otherwise merging the config files manually with kdiff3, but is there a better way to do it?
Also, do I have to backup the old file somewhere myself or does dpkg automatically make a backup? I sometimes I noticed .old files in some directories for old versions of config files.
This issue is complicated by the fact that since I'm new to this group, I don't know why some changes are the way they are, but if in doubt I've been deferring to the existing version.
By the way, I'd like some specificity. Eg, when dpkg prompts you with the whole Y/N/I/O/D/etc thing, what do you do? Do you back up the old file, install the new one, and then merge, or is there a better way to merge the files when you're in that ncurses prompt thing?
Solution 1:
that seems like a reasonable way of doing it. similar to what i've been doing for about 15 years (been using debian since 1994). it's always worked for me :)
i start with the basic assumption that if i've modified a config file, then i had a good reason for it, and my changes are likely to be better/more important than anything in the new default config file.
i then examine both my config and the new packaged version and either:
completely ignore any differences because they're either not important or not relevant to my setup.
merge anything useful from the new config into my existing config.
if there's a lot of new stuff and only a small amount of my changes that i want to keep, then i do the reverse and merge my changes into the new config file and then use that.
i don't use any specialised or GUI tools for this. i just use 'diff -u' and less and vi plus occasionally some of the standard text processing tools like sed or perl. colordiff is nice, too, when the diff output is more than a screenful or so.
Solution 2:
Although I agree with Craig Sanders' answer, I have to add one caveat: During many upgrades (usually between releases -- like Hardy --> Intrepid) apt reports config files as changes when I haven't changed them. If I'm confident that I haven't changed a config file, I'll just choose to dump the old one and keep the package maintainer's version.
Solution 3:
Just spotted this post looking for the answer to a similar question of mine.
What I ended up doing after all is choose to open a terminal, do a 3-way merge with meld,
meld file.conf file.conf.dpkg-old file.conf.dpkg-new
save the result to file.conf and go on with that