#站点目录 WEBSITE_DIR='/data/wwwroot/xxxx.com/'; #备份文件夹 BACKUP_DIR='/home/backup/'; #站点备份文件名 DATETIME=`date +%Y%m%d%H%M%S` BACKUP_FILENAME=$BACKUP_DIR'xxxx.com-'$DATETIME'.tar.gz'; BACKUP_TMP_DIR=$BACKUP_DIR'_tmp/'; if [ ! -d $BACKUP_TMP_DIR ]; then mkdir $BACKUP_TMP_DIR; fi CONFIG_DIR=/usr/local/nginx/; NGINX_CUT_LOG_SHELL="$CONFIG_DIR"cut_access_log.sh; NGINX_CONF="$CONFIG_DIR"conf/nginx.conf; CONFIG_FILES=("$NGINX_CUT_LOG_SHELL" "$NGINX_CONF"); for config_file in ${CONFIG_FILES[@]}; do #echo $config_file; cp $config_file $BACKUP_TMP_DIR done #mysql账户信息 MYSQL_HOST='127.0.0.1'; MYSQL_USER='dbuser'; MYSQL_PASS='12345678'; MYSQL_DB_LIST=("dbname1" "dbname2"); cp -r $WEBSITE_DIR* $BACKUP_TMP_DIR cd $BACKUP_DIR for db in ${MYSQL_DB_LIST[@]}; do echo $db; #mysqldump -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$db" | gzip > $BACKUP_TMP_DIR$db-$DATETIME.sql mysqldump -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$db" > $BACKUP_TMP_DIR$db-$DATETIME.sql done echo $BACKUP_FILENAME; tar -cvzf $BACKUP_FILENAME $BACKUP_TMP_DIR* rm -rf $BACKUP_TMP_DIR;
网站备份打包
阅读45评论02019-08-27 15:02:55
访客评论