After reading my last post a second time I realized that without further explanation the diff-binary.sh
and patch-binary.sh
scripts look just like a wrapper around a specific rsync
call. But there is a little bit more to it. Therefore, this post describes the rationale behind these scripts and enhances them to some extent (with input handling & hashing).
Tag: Bash
Find Missing Files in a Backup
Long time no write… I had many ideas for blog posts, but no time to write them. Hopefully, this will change soon. Here just a small update… As you know (if you read my blog), I have a “special” way of storing and “backupping” my files. All my documents are stored in a folder named YYYY/
(e.g. 2021
) and have the format YYYYMMDD-<some-name>.<some-ending>
. I further categorize my files by using macOS tags.
Every year I prepare a folder tax-YYYY/
, where I copy all the files with relevance to my tax declaration. But sometimes I am not completely sure whether all the files in there are in my main YYYY/
folders, too. This is, because I copy files from my e-mail (like invoices) and some files, which relate to year YYYY
are from YYYY+1
, e.g. the proof of social security. So, after finishing the tax declaration I double check, whether every file that belongs to a year made its way into the corresponding folder with a dedicated unix command (here exemplarily for 2019
). For sure this can be used to check the completeness of backup folders, too. A recursive variant may even be used to search complete backups for missing duplicates/files. So here is the command.
ls 2019* | while read file; do; \ found=$(find ../2019 -name $file | wc -l); \ if [ $found -eq 0 ]; then; echo $file; fi; \ done
Be aware, that this does only search for a file with the same name. It does not check whether it is not the same file (e.g. due to file changes). This can be done by using a hashing algorithm
Exciting 🤓.