dobackup: collect errors instead of failing, show them at end

This commit is contained in:
gutmet 2022-09-19 11:20:50 +02:00
parent c067ed87f9
commit 19db27d6bf

View File

@ -30,6 +30,9 @@ source $1
timestamp=`date +"%Y%m%d-%H%M"` timestamp=`date +"%Y%m%d-%H%M"`
dest="$HOME/backups/$name-$timestamp" dest="$HOME/backups/$name-$timestamp"
errfile="$name-$timestamp.errs"
touch errfile
if [ "$remote" = true ]; then if [ "$remote" = true ]; then
if [ -z "$sshUserHost" ]; then if [ -z "$sshUserHost" ]; then
@ -48,12 +51,10 @@ eval ${precommand}
for file in $files; do for file in $files; do
fullcommand="$command$file $dest" fullcommand="$command$file $dest"
echo "$fullcommand" echo "$fullcommand"
if [ "$remote" = true ]; then $fullcommand 2>>"$errfile"
$fullcommand
else
$fullcommand || exit 1
fi
done done
echo "$postcommand" echo "$postcommand"
eval ${postcommand} eval ${postcommand}
cat "$errfile"