728x90
반응형
mkdir /etc/cron.exe
vi /etc/crontab
cd /etc/cron.exe
touch backup.cron
vi backup.cron
#!/bin/sh
DIRECTORY="/home/work"
BACKUPDIR="/backup"
INCREMENTAL=$BACKUPDIR/backuplist
week=`date +%u`
DM=`date +%d-%m-%y`
if [ ! -d $BACKUPDIR ]
then
mkdir $BACKUPDIR
fi
if [ ! -f $BACKUPDIR/Fullbackup* ]
then
tar cpfz $BACKUPDIR/Fullbackup-$DM.tar.gz $DIRECTORY
else
if [ $week = 7 ]
then
rm -f $BACKUPDIR/*
tar cpfz $BACKUPDIR/Fullbackup-$DM.tar.gz $DIRECTORY
else
tar cpfz $BACKUPDIR/Incremental-$DM.tar.gz
-g $INCREMENTAL $DIRECTORY
fi
fi
bash backup.cron
ls /backup
chmod 755 backup.cron
vi /etc/crontab
50 11 * * * root run-parts /etc/cron.exe
setup -> system service -> crond chk
service crond restart
service xinetd restart
service crond status
date 14072009
ls -l /backup
-> Fullbackup-xxxxx.tar.gz
date 123111492007
service crond restart
service xinetd restart
ls -l /backup
-> Fullbackup-xxxxx.tar.gz
-> Incremental-xxxxx.tar.gz
-> backuplist
728x90
반응형
댓글