This commit is contained in:
Michael Rodin 2023-09-02 21:41:59 +02:00
parent 0435efe615
commit 450785bd70

View file

@ -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:<file> 2:<remotedir>
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