#!/bin/bashbakdir=/data/backup/fileback
filedir=/docker/bitbucket/var/
logdir=/tools/backup/filebaklog/`date +%w`filebackup.log
receive=xxx@ali.com
get_ip() {
cmd_get_ip=$(/sbin/ifconfig |grep "192.168.1\." |awk -F ' ''{print $2}'|tr -d "地址:"|tr -d "addr:")echo$cmd_get_ip}
ip=$(get_ip)bak() {
cd$bakdirfind ./ -name \*.tar.gz -mtime+6-deletecd$filedirecho`date`'/docker/bitbucket/var/atlassian/路径备份开始' > $logdirtar -zcvf$bakdir/`date +%Y%m%d`atlassian.tar.gz atlassian/ >> $logdir2>&1
echo`date`'/docker/bitbucket/var/atlassian/路径备份结束' >> $logdir}
dubakdir() {
echo-e"备份存储路径:$bakdir\\n`ls -lh $bakdir/`" | mail -s$ip'文件备份情况成功'$receive}
if [ -d$filedir ];then
if [ -d$bakdir ];then
bak
dubakdir
elseecho$ip'备份存储路径被删除,即将重新建立,继续备份'| mail -s$ip'备份路径异常'$receivemkdir-p$bakdir bak
dubakdir
fielseecho$ip'要备份目录丢失,备份失败'|mail -s$ip'目录备份失败'$receive dubakdir
fi