Confirm that data paths aren't emnpty

This commit is contained in:
Charlie Root 2019-03-14 12:03:05 +11:00
parent 82be16bc42
commit a7f7768567
1 changed files with 16 additions and 3 deletions

19
bare.sh
View File

@ -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