#!/bin/bash path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export path ###備份源目錄 dir="/home/backup" ###備份目的目錄 backup="/home/backup/web_backup" ###名字 filename="cpiaoju.tar.gz" ###時間 backtime=`date +%Y%m%d` [ ! -e "$dir" ] && echo "請聯繫管理員" && exit [ ! -e "$backup" ] && mkdir $backup /bin/mkdir $backup/$backtime cd $backup /bin/tar zcfvP $backup/$backtime/$filename $dir/ find "$backup" -name "cpiaoju.tar.gz" -type f -mtime +7 -exec rm {} \;> /dev/null 2>&1