Nicer structure for auto-added files #838
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#838
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'd like to do and why
I'm fascinated by the power and simplicity that borg(matic) bring to backups. There are just some minor things that would make it even better. One of them is regarding the files that get added automatically. Currently it looks like this:
It's a mix of the backup configuration, database dumps and state information. All of them reflect the local file system structure, which I tried to avoid with a
working_directory
setting.In borg version 2.0.0b8 and upcoming 1.4, there's a feature to use a path
/strip/prefix/./keep/postfix
which will result in a filekeep/postfix
being archived. It could be used to ask borg to backup/etc/borgmatic.d/./server.yaml
and/root/./.borgmatic
, which would result in this layout:And the good thing is that it's backwards-compatible, resulting in the original layout for older borg versions.
Ideally, I'd like to move the config to
.borgmatic
. That would be possible with one of the further ideas in https://github.com/borgbackup/borg/issues/4685.What do you think?
Other notes / implementation ideas
No response
Thanks for taking the time to file this! I think taking advantage of Borg's upcoming prefix stripping feature as you describe could work great for the archived files in
.borgmatic
, especially for things like database dumps that are currently tied to the current user. However I do wonder about how manually extracting such files would work in practice. For instance, if all that's stored in the archive is a path that begins with.borgmatic
instead of, say,/root
, how will the user know where to extract it?Similarly, with the case of config files, part of the purpose of the feature is to be able to easily restore them back to their original locations with the
borgmatic bootstrap
action. But if the stored config file paths are relative instead of absolute, how will that work?Also, I think one thing missing for me here is why you want this feature. You mention:
Why are you trying to avoid reflecting the local filesystem structure? And what's your use case / plan for extracting these files from an archive?
Let me start with the why and some context:
I started using borg(matic) for a small home server. My intentions will probably differ from those of companies responsible for a huge farm of automated, "cattle"-like servers.
In this case, I want to back up the data of an Immich instance (Google Photos replacement). So just one "app", not the whole server, that might also be an important differentiator. Anyway, the data is currently stored on
/media/nas/immich
, but that's not set in stone. I might be moving the data to some other disk tomorrow if I decide to optimize my server structure, or I might want to restore it to another server with a different base directory. So the absolute path is an implementation detail which I don't want to back up, my focus on ensuring that the actual data is safe. If I do move the folder,borg diff
shouldn't show a huge list of added/removed files.That's why I use
working_directory
, which is sufficient because Immich's data is all under a single folder. Now the filesystem data is stored as relative paths, but the "generated" files still use absolute paths. This mix is not so nice, and besides that, having a single.borgmatic/
entry point would make it totally clear where the data came from, rather than seeingetc/
androot/
.You could also see it as a separation of concerns - I'd like borgmatic to put all its stuff into a single, root-level folder.
I can't answer the questions about
borgmatic bootstrap
as I haven't used that feature yet. In my case, I probably wouldn't rely on automatic restores. I would be happy that I can get my destroyed data back, and if it takes three commands to extract the folders to their respective locations, that's fine as wellFor
.borgmatic
, I guess you could handle it as a "magic" location and always restore it to the home directory if needed. It would also be in a fixed location (well, if using the slash-dot), so you don't have to search for it. Currently, it could be in/root/.borgmatic
, but also in/home/someuser/.borgmatic
, right?That would leave only the config questionable. Copying/linking it to
/root/.borgmatic/config.yaml
(or maybe an extension of the slash-dot feature) would also bring that to a fixed location with similar benefits. If there's a requirement to restore the config to the original path, could that information be taken frombootstrap/manifest.json
?Or another idea: Back up the config to
.borgmatic/etc/borgmatic.d/server.yaml
, then the original paths can be found by just stripping the prefix. Again, these is just some food for thoughts, there might be better implementations.NB: Does borgmatic ensure that only a single process is running? Since the
/root/.borgmatic
directory seems to be shared across different repositories and configs, it has to be ensured that e.g. a database being dumped for process 1 isn't written to the backup if process 2. I assume subfolders (per repository? per config?) would make this safer, but I have no idea what other checks are already in place.Thanks for getting into your rationale here, and what you describe makes sense to me for
~/.borgmatic
. One way it could work is that when looking for database dumps to restore, borgmatic could first probe for.borgmatic
within the archive before falling back to~/.borgmatic
(based on the current user) for backwards compatibility. And of course storing.borgmatic
instead of~/.borgmatic
would have to wait for for Borg 1.4. But it seems like a reasonable approach to me.I'm still not convinced though on the suggestions for storing config file paths. It seems unnecessary to encode the original path of a configuration file within
bootstrap/manifest.json
or a.borgmatic
sub-path when there's already a perfectly good mechanism for encoding the original path of an archived file—the full file path as its stored within the Borg archive! Using the full file path for that also has the relatively minor benefit that each config file is stored only once even if a user backs up their config files by adding them tosource_directories
.If you really don't want the auto-storing of config files necessary for
borgmatic bootstrap
though, you can always setstore_config_files: false
in your configuration.No, borgmatic itself doesn't currently ensure that it isn't run more than once, but typically that responsibility would fall to whatever is running borgmatic (e.g. systemd, which does do that IIRC). And you correct that simultaneous borgmatic runs with database dumps would encounter problems.
Related ticket, maybe good to tackle at the same time: #562