diff --git a/backup-rclone.sh b/backup-rclone.sh index 70102d3..f1542f7 100755 --- a/backup-rclone.sh +++ b/backup-rclone.sh @@ -25,7 +25,7 @@ recursive_backup() { #remotehash="$(cat $hashtemp | grep -n "$k")" # old databese sqlcommand="SELECT hash FROM files WHERE backpath=\"${k}\";" remotehash="""$(sqlite3 $hashtemp "$sqlcommand")""" # get hash from database - if [[ -z $remotehash ]]; then entryexists=false; else entryexists=true; fi # if file entry (and hash) exists, save as bool + if [[ -z $remotehash ]]; then entryexists=0; else entryexists=1; fi # if file entry (and hash) exists, save as bool localhash="$(md5sum "$k")" # hash of local version of file localhash="${localhash%% *}" done_files=$(($done_files+1)) @@ -58,7 +58,7 @@ backup() { # backup 1: 2: bool=0 rclone copy "$1" "$2" && bool=1 #if [[ $remoteline == "0" && $bool == 1 ]]; then echo "$localhash" >> $hashtemp; else sed -i "${remoteline}s|.*|${localhash}|" $hashtemp; fi # TODO: SQL ###### - if [[ $bool==1 && $entryexists ]]; then + if [[ $bool==1 && $entryexists == 1 ]]; then sqlcommand="UPDATE files SET hash=\"${localhash}\" WHERE backpath=\"${2}\"" #set new hash in database sqlite3 $hashtemp "$sqlcommand" else