首页 > 代码库 > 每日备份脚本目录shell

每日备份脚本目录shell

#!/bin/sh

#please user the Full Path Directory


SiteName="www.sijisiji.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

每日备份脚本目录shell