#!/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
时间: 2024-10-22 01:18:37