请教备份网站的脚本
军哥: 我最近在军哥网站上学习备份的脚本,按要求修改了备份的参数,很好用!现我想把网站数据和数据库分开备份,网站数据按半个月一次来备份,备份完后删除本地文件,我应该怎么改下面的脚本?谢谢!
#!/bin/bash
#Funciont: Backup website
#Author: licess
#Website: https://lnmp.org
#IMPORTANT!!!Please Setting the following Values!
Backup_Home="/home/backup/"
######~Set Directory you want to backup~######
Backup_Dir=("/home/wwwroot/vpser.net" "/home/wwwroot/lnmp.org")
######~Enable Ftp Backup~######
Enable_FTP=0
# 0: enable; 1: disable
######~Set FTP Information~######
FTP_Host='1.2.3.4'
FTP_Username='vpser.net'
FTP_Password='yourftppassword'
FTP_Dir="backup"
#Values Setting END!
TodayWWWBackup=www-*-$(date +"%Y%m%d").tar.gz
OldWWWBackup=www-*-$(date -d -3day +"%Y%m%d").tar.gz
Backup_Dir()
{
Backup_Path=$1
Dir_Name=`echo ${Backup_Path##*/}`
Pre_Dir=`echo ${Backup_Path}|sed 's/'${Dir_Name}'//g'`
tar zcf ${Backup_Home}www-${Dir_Name}-$(date +"%Y%m%d").tar.gz -C ${Pre_Dir} ${Dir_Name}
}
if [ ${Enable_FTP} = 0 ]; then
type lftp >/dev/null 2>&1 || { echo >&2 "lftp command not found. Install: centos:yum install lftp,debian/ubuntu:apt-get install lftp."; }
fi
echo "Backup website files..."
for dd in ${Backup_Dir[@]};do
Backup_Dir ${dd}
done
echo "Delete old backup files..."
rm -f ${Backup_Home}${OldWWWBackup}
if [ ${Enable_FTP} = 0 ]; then
echo "Uploading backup files to ftp..."
cd ${Backup_Home}
lftp ${FTP_Host} -u ${FTP_Username},${FTP_Password} << EOF
cd ${FTP_Dir}
mrm ${OldWWWBackup}
mput ${TodayWWWBackup}
bye
EOF
echo "complete."
fi 分成两个脚本,一个把mysql备份删掉,一个把网址备份代码删掉就行了 备份完后自动删除本地文件,我应该怎么改备份的脚本?
回复 3# 的帖子
自己改的话还是需要有些linux和shell基础的,https://lnmp.org/faq/lnmp-1-2-tools.html 官网上有详细的参数的说明 https://www.vpser.net/vps-howto 这里也有些基本的教程本地的删除需要自己再参考脚本添加 rm 删除本地文件
如果需要另外定制脚本,可以联系旺旺:lzhenbao 付费编写。 谢谢军哥!
页:
[1]