每日备份脚本目录shell

#!/bin/sh

#please user the Full Path Directory


SiteName="www.xxx.com"

Prefix=`date +%Y%m%d`

Cur_Bak_Name=${SiteName}"_"${Prefix}"_bak"

Cur_Bak_Name_gz=${Cur_Bak_Name}".tar.gz"

BackupDir="/home/backup"

SiteDir="/home/wwwroot"

if [ ! -f $BackupDir ]; then
mkdir -p $BackupDir
fi


if [ -f ${BackupDir}/$Cur_Bak_Name_gz ]; then
rm ${BackupDir}/$Cur_Bak_Name_gz
fi


cp -r ${SiteDir}/${SiteName}/ ${BackupDir}/${Cur_Bak_Name}/


cd ${BackupDir}

tar -czvf ${Cur_Bak_Name_gz} ${Cur_Bak_Name}

if [ -d ${BackupDir}/$Cur_Bak_Name ]; then
cd ${BackupDir}
rm -fr ${Cur_Bak_Name}
fi

posted @ 2017-03-25 18:17  两年十一时  阅读(432)  评论(0编辑  收藏  举报