On Monday 14 October 2002 12:37, Erez Boym wrote:
I use this not too sofisticated script:
#!/bin/bash
#
# Creates backups of essential files. After the completion, sends log to
predefined address.
# Full backup is made at Saturday ("Shabbat"). Incremental backups are made
every weekday.
# In order for this script to work:
# 1 appropriate crontabentry should be made
# 2 THE FIRST RUN OF THIS SCRIPT SHOUD BE ON SATURDAY
# 3 status directory should be created. This directory serves for time
trakking, so biweekly cleanup
# is performed
# 4 a little bit of luck :-)
#
BACKUPDIR="/backup"
TEMPDIR="/tmp"
STATUSDIR="/backup/status"
DATA="/home /root"
CONFIG="/etc /var/lib "
#DATA="/home/bgbg/backuptest/data_test"
#CONFIG="/home/bgbg/backuptest/conf_test"
LIST="$TEMPDIR/backlist_$$.txt"
NOLIST="$TEMPDIR/nolist_$$.txt"
ERRORFILE="$TEMPDIR/backuperrors_$$.txt"
LOGFILE="$TEMPDIR/backuplog_$$.txt"
MAILTO="root" # any mail address
# let's start
echo "Backup script started on `date`">$LOGFILE
chmod -R 700 $BACKUPDIR
chmod -R 700 $STATUSDIR
#############################################################
############### NOLIST files and directories that should not be backuped
######################################
#############################################################
#we don't backup files in trash, temp, tmp, cache directories (case
insensitive)
# in fact, any directory that has a name that ends with those strings will be
excluded
find $DATA -depth | grep -iE 'temp/
trash/
tmp/
cache/
music/
mp3/
downloads/
dontbackup/'>$NOLIST
STATUS=`ls -l $STATUSDIR/ | wc -l`
let "STATUS = STATUS -1"
set $(date)
#
if test "$1" = "Sat" ; then
# weekly full backup of all data and config. settings:
#
if test $STATUS = 14; then
#biweekly cleanup
echo "Biweekly cleanup. SKIPPED `date`">>$LOGFILE
rm -f $BACKUPDIR/data_full* 2>>$ERRORFILE
rm -f $BACKUPDIR/config_full* 2>>$ERRORFILE
fi
echo "weekly a full backup of all data and config. settings
`date`">>$LOGFILE
tar cfz "$BACKUPDIR/data_full_$6-$2-$3.tgz" $DATA -X $NOLIST
2>>$ERRORFILE
#
tar cfz "$BACKUPDIR/config_full_$6-$2-$3.tgz" $CONFIG -X $NOLIST
2>>$ERRORFILE
if test $STATUS = 14; then
#biweekly cleanup
echo "Biweekly cleanup. Removing incremental backups
`date`">>$LOGFILE
rm -f $BACKUPDIR/data_diff* 2>>$ERRORFILE
rm -f $BACKUPDIR/config_diff* 2>>$ERRORFILE
echo "!!!!!!!!!!!! DON'T FORGET TO TRANSFER THE FULL BACKUP
TO CD !!!!!!!!!!!">>$LOGFILE
rm -f $STATUSDIR/* >>$ERRORFILE
echo status a $STATUS
let "STATUS = 0"
echo status a $STATUS
fi
else
# incremental backup:
#
echo "incremental backup: `date`">>$LOGFILE
find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT "$BACKUPDIR/data_diff_$6-$2-$3.tgz" "$LIST" -X $NOLIST
2>>$ERRORFILE
rm -f "$LIST" 2>>$ERRORFILE
#
find $CONFIG -depth -type f \( -ctime -1 -o -mtime -1 \) -print >
$LIST
tar cfzT "$BACKUPDIR/config_diff_$6-$2-$3.tgz" "$LIST" -X $NOLIST
2>>$ERRORFILE
rm -f "$LIST" 2>>$ERRORFILE
fi
rm -f "$NOLIST" 2>>$ERRORFILE
let "STATUS = STATUS + 1"
touch $STATUSDIR/$STATUS >>$ERRORFILE
#close backup and status directories for eddiding
chmod -R 500 $BACKUPDIR
chmod -R 500 $STATUSDIR
echo "Ended at `date`">>$LOGFILE
echo "-----------------" >>$LOGFILE
echo "ERROR log">>$LOGFILE
echo >>$LOGFILE
cat $ERRORFILE >>$LOGFILE
echo >>$LOGFILE
echo "END OF ERROR LOG">>$LOGFILE
#tell to the friends
mail $MAILTO -s "Backup log on `hostname`, `date`" <$LOGFILE
################################## END #######################3333
--
Boris Gorelik
Mon, 14/Oct/2002, 8 Heshvan 5763
-------------------------------------------------
! Molecular Modelling Group !
! Pharmacy School, Hadassa Faculty of medicine !
! The Hebrew University of Jerusalem !
! http://www.md.huji.ac.il/models/group.html !
!
!------------------------------------------------
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]