Listing 1 Backup script
#!/bin/sh
# backup an entire filesystem incrementally, or create a full backup
# if our timestamp file doesn't exist
# By Shawn Bayern
BACKUP_TIMESTAMP=/usr/local/etc/backup-timestamp
DEST_DIR=/hd2/backup
DATE=`date '+%y%m%d-%H%M%S'`
THIS_DEST=${DEST_DIR}/${DATE}
# Sanity check
if [ ! -d $DEST_DIR ]
then
echo "backup.sh: backup directory doesn't exist" 1>&2
exit -1
fi
# Record the time BEFORE we start
touch ${BACKUP_TIMESTAMP}.new
# Prepare this iteration's directory
mkdir $THIS_DEST
# Back up recently modified files (or all files, if relevant)
echo "`date`: running backup" 1>&2
if [ -f $BACKUP_TIMESTAMP ]
then
find /\(-type f -o -type |\) -a -newer $BACKUP_TIMESTAMP
else
find / -type f -o -type|
fi | egrep -v '^/proc/|^/tmp/|^/hd2/|^/mnt/|^/dev/' \
| sed 's/^/"/' | sed 's/$/"/' \
| xargs cp -aP --target-directory=$THIS_DEST
# Lock the recorded date in
mv ${BACKUP_TIMESTAMP}.new $BACKUP_TIMESTAMP
|