add this task into crontab
* * * * * flock -xn /tmp/backup_task.lock -c '/data/shell/entry.sh > /dev/null 2>&1'
#!/bin/bash | |
APP=$1 | |
DATA_PATH=/data/${APP}/data/witness_node_data_dir | |
BACKUP_PATH=/data/wwwroot/backup | |
set -x | |
docker network disconnect bridge ${APP} | |
/data/${APP}/run.sh stop | |
/usr/bin/telegram "[DACENTEC] steem-${APP} stop successfully and start backup ${APP}." | |
t=$(date +%Y%m%d) | |
find ${DATA_PATH}/blockchain -type f -name "LOG*" -delete | |
tar -cf ${BACKUP_PATH}/ing/steem_${APP}_${t}.tar.lz4 --use-compress-program=lz4 -C ${DATA_PATH} blockchain/ | |
if [[ "${APP}" = "witness" ]]; then | |
echo "backup block_log file" | |
tar -czvf ${BACKUP_PATH}/ing/block_log_${t}.tar.gz -C ${DATA_PATH}/blockchain/ block_log | |
rm -rf ${BACKUP_PATH}/block_log_*.tar.gz | |
mv ${BACKUP_PATH}/ing/block_log_${t}.tar.gz ${BACKUP_PATH}/ | |
fi | |
rm -rf ${BACKUP_PATH}/steem_${APP}_*.tar.lz4 | |
mv ${BACKUP_PATH}/ing/steem_${APP}_${t}.tar.lz4 ${BACKUP_PATH}/ | |
rm -rf ${DATA_PATH}/blockchain/* | |
/usr/bin/telegram "[DACENTEC] steem-${APP} backup finish" |
#!/bin/bash | |
set -x | |
TAG_FILE=/tmp/steem_backup_tag.txt | |
last_edit_time=`stat -c %Y ${TAG_FILE}` | |
now=`date +%s` | |
[ "${last_edit_time}" = "" ] && last_edit_time=0 | |
age=$((${now} - ${last_edit_time})) | |
if [[ ${age} -le 86400 ]]; then | |
exit 0; | |
fi | |
/data/shell/untar.sh api | |
/data/shell/backup.sh api | |
/data/shell/untar.sh ah | |
/data/shell/backup.sh ah | |
/data/shell/untar.sh witness | |
/data/shell/backup.sh witness | |
echo "${now}" > ${TAG_FILE} |
#!/bin/bash | |
APP=$1 | |
DATA_PATH=/data/${APP}/data/witness_node_data_dir | |
BACKUP_PATH=/data/wwwroot/backup | |
set -x | |
filename=`ls -lt ${BACKUP_PATH}/steem_${APP}* | head -1 | awk '{print $9}'` | |
tar --use-compress-program=lz4 -C ${DATA_PATH} -xf ${filename} | |
telegram "[DACENTEC] untar ${APP} finish" | |
/data/${APP}/run.sh start | |
/usr/bin/telegram "[DACENTEC] steem-${APP} start successfully." | |
output="" | |
while [ "$output" = "" ]; | |
do | |
output=`docker logs --tail 10000 ${APP} | grep 'transactions on block'`; | |
sleep 30; | |
done | |
/usr/bin/telegram "[DACENTEC] steem-${APP} replay successfully." |