blob: ed745a5c913118fd26db4faa1d44b87fe8aaa330 (
plain)
- #!/bin/sh
- #
- # /usr/local/sbin/localbackupconfig
- # Copyright 2001 Jonas Smedegaard <dr@jones.dk>
- #
- # $Id: localbackupconfig,v 1.6 2002-10-17 17:20:56 jonas Exp $
- #
- # .dpkg-new files appear when refusing to update a conffile on package update
- #
- # .orig files you should save yourself before customizing a configfile
- #
- # .old files are for customizing when you don't have the original (anymore)
- #
- # .bak is... eh... just in case you felt like using that name now and then...
- #
- set -e
- FQDN=`hostname -f`
- BACKUPDIR=/var/local/backups/$FQDN
- LOCALCONFIGDIR=/etc/local-$FQDN
- if [ -e $LOCALCONFIGDIR ]; then
- mkdir -p $BACKUPDIR/$LOCALCONFIGDIR
- cp -fa $LOCALCONFIGDIR $BACKUPDIR/`dirname $LOCALCONFIGDIR`/
- fi
- changedfiles=`find /etc -name '*.bak' -o -name '*.old' -o -name '*.orig' -o -name '*.dpkg-new' | sed -e 's,\.\(bak\|old\|orig\|dpkg-new\)$,,' | grep -v "^$LOCALCONFIGDIR" | sort -u`
- for i in $changedfiles; do
- if [ -e $i ]; then
- if [ -e $i.dpkg-new ]; then
- orig="$i.dpkg-new"
- elif [ -e $i.orig ]; then
- orig="$i.orig"
- elif [ -e $i.old ]; then
- orig="$i.old"
- elif [ -e $i.bak ]; then
- orig="$i.bak"
- else
- echo "What the f... Original for \"$i\" has disappeared?!?"
- exit 1
- fi
- mkdir -p $BACKUPDIR/`dirname $i`
- cp -fa $i $BACKUPDIR/`dirname $i`/
- diff -ruN $orig $i > $BACKUPDIR/$i.diff || true
- fi
- done
|