diff --git a/README.md b/README.md index c7a8755..031d734 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # foxBackup -### keys +## keys -f = full backup (if not = increment) -q - suppress logs output -### config options +## config options sqldump_prefix="docker exec -t db mysqldump" = prefix for sqldump @@ -27,3 +27,13 @@ sshkey='/path_to_ssh_private_key'; sshpath='/media/hdd2/backup'; = remote path for SCP store +# Check + +Run at backup storage, checks expired backups in all forders with prefix backup- in ``prefix`` folder. + +All deltas calculated from file names! + +## Config +prefix='/mnt/backups'; # Storage prefix +dailySecMax=936000; # DailyDelta in seconds +fullSecMax=29376000; # FullDelta in seconds diff --git a/check/check.sh b/check/check.sh new file mode 100755 index 0000000..4b2ea29 --- /dev/null +++ b/check/check.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +ABSOLUTE_FILENAME=`readlink -e "$0"` +DIRECTORY=`dirname "$ABSOLUTE_FILENAME"` + +source ${DIRECTORY}/config +currStamp=`date +%s` + +for backup_dir in `ls -d ${prefix}/backup-*` +do + echo Directory ${backup_dir}: + lastFull=`cd ${backup_dir}/ && ls -t *-[F].t* 2>/dev/null | head -n 1` + lastDaily=`cd ${backup_dir}/ && ls -t *-[DI].t* 2>/dev/null | head -n 1` + echo LF: ${lastFull:-WARN == FULL NOT FOUND} + echo LD: ${lastDaily:-WARN == DAILY NOT FOUND} + if [[ -n ${lastFull} ]] + then + lastFullStamp=`echo ${lastFull} | awk -F '-' '{ print $1 }'` + lastFullDelta=`expr ${currStamp} - ${lastFullStamp}` + if [ "${fullSecMax}" -gt "${lastFullDelta}" ] + then + echo "OK - Full delta ${lastFullDelta} OK" + else + echo "FAIL == LAST FULL EXPIRED" + fi + + fi + + if [[ -n ${lastDaily} ]] + then + lastDailyStamp=`echo ${lastDaily} | awk -F '-' '{ print $1 }'` + lastDailyDelta=`expr ${currStamp} - ${lastDailyStamp}` + if [ "${dailySecMax}" -gt "${lastDailyDelta}" ] + then + echo "OK - Daily delta ${lastDailyDelta} OK" + else + echo "FAIL == LAST DAILY EXPIRED" + fi + fi + +done + diff --git a/check/config.sample b/check/config.sample new file mode 100644 index 0000000..aa3ba04 --- /dev/null +++ b/check/config.sample @@ -0,0 +1,6 @@ +prefix='/mnt/backups'; +# 26Hrs +dailySecMax=936000; +# 34Days +fullSecMax=29376000; +