#!/bin/bash location="/home/dsMin/Backup" # 创建一个备份目录 mkdir -p $location # 备份一个SQL类型的 date_str=`date +%Y%m%d%H%M%S` mysqldump -h localhost -P 22066 -u root --password=DsideaL147258369 -R -E -e --max_allowed_packet=1048576 --net_buffer_length=16384 shl_db | gzip > $location/shl_db_$date_str.sql.gz # 删除原文件(删除超过7天的) #rm -rf ${FILE} find $location -mtime +7 -type d |xargs rm -rf