|
|
| File: [local] / openbsd / backup_config / backup_config (download)
Revision 1.11, Tue Nov 17 16:48:14 2009 UTC (16 years, 1 month ago) by andrew
find and sed instead of list directly to tar so we can archive just files and links |
#!/bin/sh
# $RedRiver: backup_config,v 1.10 2009/11/05 23:26:34 andrew Exp $
if [ `id -u` -ne 0 ]; then
echo You should run this as root! >&2
exit 255
fi
FILE=/tmp/`hostname -s`-`date +%Y-%m-%d`.tar.gz
local _maxhomesize=`dc -e '50 1024 * p'`
local _list="/root \
/etc \
/var/backups \
/var/cron \
/var/www/conf"
local _mcfile=`grep '^### .*\.mc' /etc/mail/sendmail.cf | cut -d ' ' -f 2`
if [ X"${_mcfile}" != X"" ]; then
_list="${_list} /usr/share/sendmail/cf/${_mcfile}"
fi
local _homesize=`du -ks /home/ | awk '{print $1}'`
if [ $_homesize -lt $_maxhomesize ]; then
_list="${_list} /home/"
else
echo Not backing up /home, too large!
fi
find $_list -type f -or -type l | sed -e 's/^\///' | tar -czf ${FILE} -C / -I -
echo backed up $_list to
echo "\t$FILE"