Chflags Intro
From Mac OS X Server FAQ
Any files that you are concerned about losing due to system updates and such, you should consider locking, in some way, shape, or form. It is reasonable to assume that an apple installer would only attempt to replace components of the operating system, which shouldn't be altered if you can help it. However, there is always the possibility of accidental data loss, and that may be somewhat prevented by locking.
A popular way to "lock" files in OS X Server is the chflags terminal command. You'll have to decide how you want to preserve the files; you can learn more about chflags by typing man chflags in the terminal.
Most commonly, the uchg flag is used to lock files, as this is equivalent to the "Lock" checkbox in a Finder Info window. Be careful with the others; schg in particular can be added by root during normal system operation, but only removed in single user mode.
To use chflags to lock or unlock files, use either the flag name, or the flag name preceeded by 'no', and then the file(s):
chflags uchg file chflags nouchg file
To view file flags, use the -O switch (uppercase letter) with ls:
ls -lO
This method of locking files that have been customized so they aren't overwriten by an installer is often successfull, but does have limitations. For example, what if the replacement file is necessary to support other upgraded components of the OS?. Use this method only when you are confident that the file in question will have no necessary replacements.
chflags is also commonly used to recursively unlock files so that they can be deleted more easily.
sudo chflags -R nouchg /path/to/files
There is more information about Preserving Config File Changes.
References
http://www.macosxhints.com/article.php?story=20031017061722471
