add verbose mode
This commit is contained in:
parent
d2039b040c
commit
b50a3be2c4
25
bare.sh
25
bare.sh
|
@ -22,6 +22,8 @@ LOG=/dev/stdout
|
|||
DATE=/bin/date
|
||||
DOALL=0
|
||||
REPOSTOBACKUP=""
|
||||
TESTMODE=0
|
||||
VERBOSE=0
|
||||
|
||||
function log() {
|
||||
local now
|
||||
|
@ -254,7 +256,7 @@ function do_umount() {
|
|||
}
|
||||
|
||||
# Handle args
|
||||
ARGS="acdhs:tx:"
|
||||
ARGS="acdhs:tvx:"
|
||||
|
||||
while getopts "$ARGS" i; do
|
||||
case "$i" in
|
||||
|
@ -278,6 +280,9 @@ while getopts "$ARGS" i; do
|
|||
t)
|
||||
TESTMODE=1
|
||||
;;
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid argument: $i";
|
||||
usage;
|
||||
|
@ -515,6 +520,7 @@ fi
|
|||
|
||||
errcount=0 # used for 'check' mode
|
||||
warncount=0 # used for 'check' mode
|
||||
errtext=""
|
||||
for f in $REPOSTOBACKUP; do
|
||||
REPO=${f}
|
||||
DATAPATH=$(getdatapath $REPO)
|
||||
|
@ -585,6 +591,9 @@ for f in $REPOSTOBACKUP; do
|
|||
else
|
||||
CONNECTIONSOPTS="-o b2.connections=${CONNECTIONS}"
|
||||
fi
|
||||
if [[ $VERBOSE -eq 1 ]]; then
|
||||
OTHEROPTS="$OTHEROPTS -v"
|
||||
fi
|
||||
|
||||
export RESTIC_EXCLUDEFILE=`getrepoexcludefile "$f"`
|
||||
if [[ ! -z $RESTIC_PASSWORD_FILE ]]; then
|
||||
|
@ -698,7 +707,16 @@ for f in $REPOSTOBACKUP; do
|
|||
log "ERROR: Repo ${REPO} already exists. Aborting."
|
||||
rv=1
|
||||
else
|
||||
${RESTIC} init $AUTHOPTS $CONNECTIONSOPTS >/dev/null 2>&1
|
||||
cmdtorun="${RESTIC} init $AUTHOPTS $CONNECTIONSOPTS"
|
||||
if [[ $VERBOSE -eq 1 ]]; then
|
||||
|
||||
|
||||
|
||||
log "export RESTIC_REPOSITORY=\"$REPO_PATH\""
|
||||
log "export RESTIC_PASSWORD_FILE=`getrepopassfile \"$f\"`"
|
||||
log "will run: [${cmdtorun}]"
|
||||
fi
|
||||
errtext=`${RESTIC} init $AUTHOPTS $CONNECTIONSOPTS 2>&1`
|
||||
rv=$?
|
||||
fi
|
||||
elif [[ $CMD == "forget" ]]; then
|
||||
|
@ -812,6 +830,9 @@ for f in $REPOSTOBACKUP; do
|
|||
fi
|
||||
elif [[ ! $CMD == "check" ]]; then
|
||||
log "Error: '$CMD' on repo '$REPO' failed"
|
||||
if [[ ! -z $errtext ]]; then
|
||||
log "$errtext"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! $CMD == "check" ]]; then
|
||||
|
|
Loading…
Reference in New Issue