#!/bin/bash# defineday_of_week=`date "+%u"`today=`date "+%Y%m%d"`source=/mnt/vg1/volume1/backup=/r1/# actioncd $backupif [ $day_of_week -eq 7 ]; then if [ ! -f "full$today.tar.gz" ]; then rm -rf snapshot echo starting full_backup tar -g snapshot -zvcf "full_$today.tar.gz" $source tar exccuted... fielse if [ ! -f "inc$today.tar.gz" ]; then echo starting incremental_backup tar -g snapshot -zvcf "inc_$today.tar.gz" $source echo done fifi# delete file before 7days agoecho delete old files...find $backup -type f -mtime +7 -exec rm -f {} \;
crontab:
[root@file ~]# crontab -lMAILTO=""10 */12 * * * /root/tar_backup.sh >> /root/cron_tar_backup.log[root@file ~]#