# 1.备份date文件
按每周轮播储存
# 2.shell脚本
代码语言:javascript复制#!/bin/bash
XWEEK=$(date " %w")
XTIME=$(date " %Y-%m-%d,%H:%m:%s")
XDATANAME=data_${XWEEK}.tar.gz
XLOGNAME=excute_${XWEEK}.log
XPATH=/home/summer/elasticsearch-6.3.1/databak
mkdir -p ${XPATH}
cd ${XPATH}
echo " ${XTIME}: start delete last version" > ${XLOGNAME}
rm -rf ${XDATANAME}
XTIME=$(date " %Y-%m-%d,%H:%m:%s")
echo " ${XTIME}: end delete last version,start bak data" >> ${XLOGNAME}
tar -cvzf ${XPATH}/${XDATANAME} ../data
XTIME=$(date " %Y-%m-%d,%H:%m:%s")
echo " ${XTIME}: end bak data" >> ${XLOGNAME}