Hi, A couple days after first installing debian a couple years back, I managed to mess up the passwd file in some way. I was very pleasantly surprised to find a backup version of the file on-line in /var/backups. I was quickly able to un-do whatever it was that I did.
There are also backups of dpkg.status, inetd.conf, and a few others. At the time, I wondered why backup copies of *all* the config files in /etc aren't automatically saved. There have been times that I wondered "did the configuration of foo change in the last two weeks?". I have tapes, of course, but finding the tape that holds /etc for the correct date is a bit more work than I'm willing expend. Often, I don't even _know_ what date I'm after. A couple months back, I was upgrading packages as I often do. Packages will silently update their conffiles if you haven't changed them, which is proper. One package --- which shall remain nameless to protect the guilty :-) --- changed the colour scheme of my email client to a contrastless grey letters on a grey background. I had to mess around a bit to get it back to how it was. That was the straw that made me finally write up the cron script to back up all my configuration files on-disk. The script, below, really has two functions. One is to make a backup copy of any changed file in /etc. I used "savelog" to keep the last few revisions of the files. The second function is to keep /etc a little more tidy. The script deletes all editor backup files (*~), and notifies me when there is a .dpkg-new or .dpkg-old copy lying about. I run this in cron.daily, so I keep getting reminders until I go in and clean these up by hand. After running this for a few months, I've discovered that some packages make their own backup copies of config files. Setserial, for example backs up /etc/serial.conf to /etc/.serial.conf.old. I've put exceptions in to ignore the ones I've found. The script also ignores the cache files ld.so.cache, mtab, and adjtime. I'm posting the script here, for two reasons. First, I'd appreciate knowing if there's a better way to accomplish this. Maybe it is handled in some package of which I am unaware? On the other hand, if this is not already handled somewhere, others might benefit. Perhaps this approach could be integrated into a package somewhere. #!/bin/sh # # Save a copy of any file in /etc that has been changed. set -e IDIR=/etc BDIR=/var/local/backups test -d $BDIR || mkdir -p -m755 $BDIR cd $BDIR for file in `find $IDIR -type f`; do case $file in *~) rm $file; continue;; /etc/modules.conf.old) continue;; /etc/.serial.conf.old) continue;; /etc/sgml/*.old) continue;; /etc/webmin/webmin.acl.bak) continue;; *bak|*.dpkg*|*.old) echo "Check $file"; continue;; /etc/ld.so.cache|/etc/mtab|/etc/adjtime) continue;; esac # do nothing if file is empty test -s $file || continue if [ -e ./$file ]; then cmp -s $file ./$file && continue savelog -c 15 ./$file >/dev/null else dir=`dirname $file` test -d ./$dir || mkdir -p ./$dir fi cp -p $file ./$file done -- by Rocket to the Moon, by Airplane to the Rocket, by Taxi to the Airport, by Frontdoor to the Taxi, by throwing back the blanket and laying down the legs ... - They Might Be Giants