If I move / restructure my files, restic has to rescan. It can take a long time. If restic writes file attributes containing the hash of the file, and its last modification date (mtime) we could avoid rereading files that have matching mtime. I assume restic can lookup the needed block hashes from the full file hash.
It would also make initial scan much smoother in case of incomplete full scans. It can be quite a pain to scan large TB collections, with risk of powerloss or otherwise process-death or if user realises filters are set incorrectly during the scan, as may happen multiple time during an initial scan. For each restart restic has to rescan files from the beginning and read every file completely, as it does not have a snapshot yet. This problem would be solved or at least greatly alleviated by adding hashes to file-attributes.
This could be added as an optional feature, like with a new ââuse-file-attribute-cacheâ alongside related options:
âforce
âignore-ctime
âignore-inode
âwith-atime
Since update file attributes changes ctime but not mtime (on linux), it would have to imply ââignore-ctimeâ.
On windows mtime is updated when file attributes are updated, so we would have to reset mtime after writing file attributes. This would add a small race condition risk, which would have to be documented.
Of couse when using --force along with --use-file-attribute-cache, these file attributes should ignored, but updated and written.
Additionally it would make sense to only write file attributes to larger files, as scanning a 1kb file is fast, and it is not worth the time to write and check the file attribute.
â
Additionally, we might also add an option that writes .restic.sha256 files to folders, containing the mtime in a comment like this:
#>1032561628000;40658
5d3835fb350d770816f954246aad31e522cba0291dce306c19fc7225146863cc *syslog-20250714_1752460801
Though I suspect few would use that, but the advantage is that user can use the files to verify files directly in dirs, and when moving dirs accross filesystems via samba, the checksums are preserved. Also its very fast reading checksums from 1 file pr dir rather than opening every single file in a directory. If its an option I donât think it would hurt even if few use it.
As virvum mentioned in his earlier suggestion we should (probably) omit resticâs own file attribute when restic store file attributes, or atleast update the file attribute before storeing them in restic backup.
I have been doing this for years with a md5sum tool I created, and it works great. After renaming a local share containing 8TB of data, restic had to rescan all (twice because I have data linked both via /mnt/disk, and /mnt/user), and it took several days, compared to my md5sum tool which did it in minutes.
If there is interest for this feature, I could probably give it a try and add it to restic myself.