From a7f7768567c4790d42d60818b1ac4076b9fb63a6 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Thu, 14 Mar 2019 12:03:05 +1100 Subject: [PATCH] Confirm that data paths aren't emnpty --- bare.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bare.sh b/bare.sh index 60f7556..2acb223 100755 --- a/bare.sh +++ b/bare.sh @@ -1,5 +1,5 @@ #!/bin/bash -VALIDCOMMANDS="go ls init repos stats" +VALIDCOMMANDS="go ls init repos stats diff" RCFILE=${HOME}/.backup/config AUTHFILE=${HOME}/.backup/auth @@ -214,14 +214,21 @@ for f in $REPOSTOBACKUP; do DATAPATH=$(getdatapath $f) if [[ -z $DATAPATH ]]; then - echo "can't find matching repo for $f - make sure it is listed in ${RCFILE}" + log "can't find matching repo for $f - make sure it is listed in ${RCFILE}" exit 1 fi if ! [[ -e ${DATAPATH} ]]; then - echo "Error: ${DATAPATH} doesn't exist" + log "Error: ${DATAPATH} doesn't exist" exit 1 fi + + count=`find ${DATAPATH} -type f | wc -l` + if [ $count -le 1 ]; then + log "Error: ${DATAPATH} exists but appears to be empty" + exit 1 + fi + done if [[ $TESTMODE -eq 1 ]]; then @@ -289,6 +296,9 @@ for f in $REPOSTOBACKUP; do elif [[ $CMD == "stats" ]]; then ${RESTIC} stats $AUTHOPTS $CONNECTIONSOPTS 2>&1 >> ${LOG} rv=$? + elif [[ $CMD == "diff" ]]; then + ${RESTIC} diff $AUTHOPTS $CONNECTIONSOPTS 2>&1 >> ${LOG} + rv=$? elif [[ $CMD == "init" ]]; then # check whether it already exists first! ${RESTIC} stats $AUTHOPTS $CONNECTIONSOPTS >/dev/null 2>&1 @@ -313,6 +323,9 @@ for f in $REPOSTOBACKUP; do elif [[ $CMD == "stats" ]]; then ${RCLONE} size $CONNECTIONSOPTS $SPEEDOPTS $RCLONE_REPOSITORY 2>&1 >> ${LOG} rv=$? + elif [[ $CMD == "diff" ]]; then + ${RCLONE} check $CONNECTIONSOPTS $SPEEDOPTS $RCLONE_REPOSITORY 2>&1 >> ${LOG} + rv=$? elif [[ $CMD == "init" ]]; then # check whether it already exists first! ${RCLONE} size $RCLONE_REPOSITORY >/dev/null 2>&1