Feature: Store all configs used to create an archive, inside the created archive. #697
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#697
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'm trying to do and why
For Borgmatic to restore data from just a repository and nothing else, the user needs to have the config somewhere. Having it inside the archive will make things easier for the user as borgmatic can later use that config and restore the archive, with no external help.
Other notes / implementation ideas
TODO: This should be as simple as adding the config being used to source_directories somehow?
TODO: Check how things get stored inside ~/.borgmatic (afair, every database has a folder in this folder) and then add one file with a pre-determined name (configs-list.json?) that contains info about all config files (just their path for now).
This should complete "phase 1" of Borgmatic being able to restore an archive from nothing.
I think so. This is where that happens now: https://projects.torsion.org/borgmatic-collective/borgmatic/src/branch/main/borgmatic/borg/create.py#L354
Makes sense! Maybe
~/.borgmatic/bootstrap/configs-list.json
or similar?I like the idea of doing this in discrete, shippable phases so as to keep the work tractable.
I was trying to back up all configs with:
Out of the default config_paths (used without the -c arg) that Borgmatic uses, the ones that start with /root raised an error, here's the log for clarity:
Borg raised this error:
which was not handled by Borgmatic (I even set source_directories_must_exist to false).
Why wasn't this handled by https://github.com/borgmatic-collective/borgmatic/pull/56? Also, how should I go about backing up the configs in the /root folder?
Where exactly did you put this line?
If, for instance, it came before the call to
check_all_source_directories_exist()
increate_archive()
, I would expect that feature to raise when it can't find those paths. If it came after, then I would not expect borgmatic to catch that, and it would be consistent with your observed behavior. In any case, I don't think this approach will quite work....Here's how I think you should go about backing up configs in any folder: I think you might need to probe for existence before adding them to
location_config['source_directories']
. And not to raise when they don't exist like thecheck_all_source_directories_exist()
feature, but instead just to omit them if they don't exist. The reason I say that is because unlike standard source directories, it's okay if the default config paths don't exist. They just need to be probed for one at a time and config loaded if it's present there.The good news is this is already done for you, and I think you might be able to switch out the value you add to
location_config['source_directories']
(with some annoying plumbing work). Instead ofglobal_arguments.config_paths
, which is the raw, unprocessed set of config paths that may or may not exist, you need the output ofborgmatic/config/collect.py:collect_config_filenames()
...borgmatic/commands/borgmatic.py:main()
.collect_configuration_run_summary_logs()
withconfigs
(a map from processed config filename to loaded config).run_configuration()
on a single config file.run_actions()
.borgmatic/actions/create.py:run_create()
.borgmatic/borg/create.py:create_archive()
, which is where you presumably need the full list of configs so you can add them to source directories.So maybe the thing to do is to pass the config filename list into
run_configuration()
and all the way down tocreate_archive()
? If you can think of a better approach, that's fine too.@diivi It occurs to me that
borgmatic bootstrap
could be renamed toborgmatic config bootstrap
, especially if all it's doing is extracting config. Related ticket: #529.For the record: The bulk of this was implemented in: https://github.com/borgmatic-collective/borgmatic/pull/71
I tried this feature and it works great! However one thing that occurs to me is that it's not storing absolute paths for config files that are specified as relative paths. Which means that when you go to bootstrap, if you don't happen to be in the same directory where the backup was taken, then the config file won't get extracted into the right place. So do you think it makes sense to
abspath()
all config files before storing them?FYI:
bbc7f0596c
... I haven't done this for Fish shell though, because honestly I don't understand how its completions work.Just released in borgmatic 1.7.15. I'm leaving the ticket open for now pending documentation.
Docs are complete, courtesy of @diivi! https://torsion.org/borgmatic/docs/how-to/extract-a-backup/#extract-the-configuration-files-used-to-create-an-archive