Probably a dumb question: Is it safe to delete the many empty directories created under /Data in the repo? If so, is there a way to automatically delete them apart from regularly running find /path/to/repo/ -empty -type d -delete
?
I guess it’s safe to delete them, since directories don’t really exist in most popular object storages, like S3, and Restic works fine with them.
Also, I do it all the time with rclone rmdirs
.
Note that there are exactly 256 directories to cover the first byte (= first 2 hex-numbers) of the filenames (= hashes) of the pack files. With larger number of pack files there will be much less empty dirs as the pack files are randomly distributed (or at least this is the assumption for a cryptographic hash) over those dir.
You can compute the expected number of empty dirs for a given number of pack files as a math exercise
TL;DR: The existence of lots of empty dirs is just an edge case for very small repositories…
Thanks for the advice and reassurance. (I’m slightly miffed that my repo is considered so small as to be the culprit for creating all those empty /data directories, but I’ll get over it. )
Restic is great software, thanks to the devs and forum for support…
hello @rustycanb and @bazinga, why would one delete empty folders in the repository?
They are already limited in quantity as mentioned, but more importantly it is the foundation of your backup. I would not do anything to risk that I can break restic in any way and jeopardise my repository. If it ain´t broken don´t fix it!
And remember, people don´t need backups they need restore.
You have a good point! But don’t worry. My repositories (and all of the independent copies, with some of them versioned over time) are intact. I play around only in a “sandbox” environment, where I pretend to break things and learn how to fix them. I also run the latest development build there, to play with the still unreleased features.
I don’t see any point in deleting those empty directories.
There is no directory named Data
in/under your repository, it’s named data
.
Yes, restic will create missing directories under the data/
directory in your repository when you run backup
, so it’s safe.
Restic does naturally not delete any of those directories, neither manually nor automatically, so it’s entirely a question outside of what restic does. You can automate this in many different ways, but again it’s a rather pointless thing to do.
Thanks for your response, and that’s exactly why I asked the question. However, after backing up my repo, I deleted nearly 200 empty directories and the repo passed restic check --read-data
, reporting no errors, as it did before the deletions.
@rawtaz It’s just my overworked tidy mind , and yes, of course, its
data
not Data
, sorry.