Created
September 12, 2014 13:36
-
-
Save oott123/71a19268fd0effcde9df to your computer and use it in GitHub Desktop.
Full Backup Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
Err() { echo -ne "\e[1;31m"; Log "$@" 1>&2; echo -ne "\e[0m";} | |
Log() { echo $(date +"[%Y-%m-%d %H:%M:%S]") $@; } | |
Log ====每日备份脚本开始运行==== | |
UPLOADER_BIN="/root/auto-scripts/bpcs_uploader/bpcs" #bpcs 上传脚本路径(见下方bpcs文件) | |
REMOTE_DIR=$(date +"%Y%m")/$(date +"%Y%m%d") # 远端上传路径 | |
WORKING_DIR="/root/auto-scripts/backup_daily" # 工作路径 | |
CONFIG_DIR=$WORKING_DIR/list.d #配置文件路径 | |
BACKUP_DIR=$WORKING_DIR/backups #本地备份路径 | |
CURRENT_DIR=$BACKUP_DIR/$(date +"%Y%m%d") | |
OLD_DIR=$BACKUP_DIR/$(date -d -3day +"%Y%m%d") | |
zipPassword=ChangeThePasswordToYourOwn #备份密码 | |
#准备删除老文件 | |
Log 删除旧备份文件夹:$OLD_DIR | |
rm -rf $OLD_DIR | |
#创建新目录 | |
mkdir -p $CURRENT_DIR | |
#遍历配置目录,进行备份 | |
for i in $(ls $CONFIG_DIR) | |
do | |
zipExclude="*/cache/* */tmp/* */temp/* */.npm/* */data/threadcache/*" | |
. $CONFIG_DIR/$i | |
Log 备份$backupDir为$i…… | |
backupFile=$i.zip | |
zip -r -P $zipPassword $CURRENT_DIR/$backupFile $backupDir -x $zipExclude | |
Log 上传备份…… | |
$UPLOADER_BIN upload $CURRENT_DIR/$backupFile $REMOTE_DIR/$backupFile | |
done | |
Log 备份完成! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
/usr/bin/php -d disable_functions -d safe_mode=Off /root/auto-scripts/bpcs_uploader/bpcs_uploader.php $* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backupDir="/etc/" | |
zipExclude=$zipExclude" *ntpd* *httpd*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment