Backups include unnecessary config files #725

Closed
opened 2023-07-14 15:03:22 +00:00 by hop · 7 comments

How to reproduce

Put several config files in a conf.d/ directory and start with borgmatic -c conf.d.

.
├── conf.d
│   ├── a.yaml
│   └── b.yaml
├── fs
│   └── data
└── repo
    ├── README
    ├── config
    ├── data
    ...

a.yaml:

location:
    source_directories:
        - $HOME/borg_test/fs

    repositories:
        - path: $HOME/borg_test/repo
          label: repo_a

storage:
    archive_name_format: 'a-{now}'

retention:
    keep_daily: 7

Same for /etc/borgmatic.d/ and borgmatic without arguments.

Actual behavior

borgmatic includes all config files in all backups.

$ borgmatic -c conf.d --verbosity 2
...
borg create $HOME/borg_test/repo::a-{now} $HOME/.borgmatic $HOME/borg_test/conf.d/a.yaml $HOME/borg_test/conf.d/b.yaml $HOME/borg_test/fs --debug --show-rc
$ borg list repo::a-2023-07-14T16:34:48
drwxr-xr-x user    staff    0 Thu, 2023-07-13 23:32:04 $HOME/.borgmatic
...
-rw------- user    staff  228 Fri, 2023-07-14 16:12:13 $HOME/borg_test/conf.d/a.yaml
-rw------- user    staff  228 Fri, 2023-07-14 16:12:11 $HOME/borg_test/conf.d/b.yaml
drwxr-xr-x user    staff    0 Thu, 2023-07-13 23:40:37 $HOME/borg_test/fs
-rw-r--r-- user    staff  139 Thu, 2023-07-13 23:40:37 $HOME/borg_test/fs/data

Expected behavior

I wouldn't have expected b.yaml to be included in a-backups and vice versa. I also think this could lead to leaked passphrases or other sensitive data.

Environment

borgmatic version: 1.7.15

borgmatic installation method: pip

Borg version: 1.1.15, 1.2.4

Python version: 3.11

Database version (if applicable): n/a

operating system and version: Debian, macOS

#### How to reproduce Put several config files in a `conf.d/` directory and start with `borgmatic -c conf.d`. ``` . ├── conf.d │   ├── a.yaml │   └── b.yaml ├── fs │   └── data └── repo ├── README ├── config ├── data ... ``` **a.yaml**: ```yaml location: source_directories: - $HOME/borg_test/fs repositories: - path: $HOME/borg_test/repo label: repo_a storage: archive_name_format: 'a-{now}' retention: keep_daily: 7 ``` Same for `/etc/borgmatic.d/` and `borgmatic` without arguments. #### Actual behavior borgmatic includes _all_ config files in all backups. ``` $ borgmatic -c conf.d --verbosity 2 ... borg create $HOME/borg_test/repo::a-{now} $HOME/.borgmatic $HOME/borg_test/conf.d/a.yaml $HOME/borg_test/conf.d/b.yaml $HOME/borg_test/fs --debug --show-rc ``` ``` $ borg list repo::a-2023-07-14T16:34:48 drwxr-xr-x user staff 0 Thu, 2023-07-13 23:32:04 $HOME/.borgmatic ... -rw------- user staff 228 Fri, 2023-07-14 16:12:13 $HOME/borg_test/conf.d/a.yaml -rw------- user staff 228 Fri, 2023-07-14 16:12:11 $HOME/borg_test/conf.d/b.yaml drwxr-xr-x user staff 0 Thu, 2023-07-13 23:40:37 $HOME/borg_test/fs -rw-r--r-- user staff 139 Thu, 2023-07-13 23:40:37 $HOME/borg_test/fs/data ``` #### Expected behavior I wouldn't have expected `b.yaml` to be included in a-backups and vice versa. I also think this could lead to leaked passphrases or other sensitive data. #### Environment **borgmatic version:** 1.7.15 **borgmatic installation method:** pip **Borg version:** 1.1.15, 1.2.4 **Python version:** 3.11 **Database version (if applicable):** n/a **operating system and version:** Debian, macOS
Owner

Thanks for taking the time to file this. Config files are included in each repository in order to support the (soon-to-be documented) config bootstrap action. The idea is that you should be able to "bootstrap" a fresh system from your backups, and the first step in doing that is to extract all borgmatic configuration files so then borgmatic can work. If each repository only contained a partial set of the configuration files, that wouldn't be possible without multiple config bootstrap invocations. Hope that makes sense.

Thanks for taking the time to file this. Config files are included in each repository in order to support the (soon-to-be documented) [`config bootstrap` action](https://projects.torsion.org/borgmatic-collective/borgmatic/issues/697). The idea is that you should be able to "bootstrap" a fresh system from your backups, and the first step in doing that is to extract all borgmatic configuration files so then borgmatic can work. If each repository only contained a partial set of the configuration files, that wouldn't be possible without multiple `config bootstrap` invocations. Hope that makes sense.
Author

It absolutely makes sense, but I don't need b.yaml in my backup of a. The above example should maybe use two different repos to make this a bit clearer.

The use case is to be able to give different clients or users different keys and be able to give them access to only their own repository.

I could iterate over the config files myself and invoke borgmatic for each of them separately, I guess, but some mechanism to do that for a single invocation would be nice.

… if /that/ makes sense.

It absolutely makes sense, but I don't need `b.yaml` in my backup of `a`. The above example should maybe use two different repos to make this a bit clearer. The use case is to be able to give different clients or users different keys and be able to give them access to only their own repository. I could iterate over the config files myself and invoke borgmatic for each of them separately, I guess, but some mechanism to do that for a single invocation would be nice. … if /that/ makes sense.
Owner

That makes sense, although that change would make the bootstrap feature potentially less useful for other use cases. (Like restoring all configs with a single borgmatic command.) So here are a few different ideas on how to address this:

  • Add a configuration option for disabling the automatic storing of configuration files altogether. This would prevent the bootstrap action from working, but it'd avoid leaking any information across repositories.
  • Or.. Add a configuration option for restricting automatic storing of configuration files to only the repositories used in those configuration files. This would make the bootstrap action less useful, but it'd still work. And a user would have to intentionally opt in to this.
  • Or.. Optionally encrypt configuration files as stored in each repository with a key specified on the borgmatic config bootstrap command-line. I'm not a huge fan of this idea though, as: 1. It's encrypting something already store in an encrypted repository, and 2. borgmatic would have to get into the business of encryption, which right now it 100% farms out to Borg. The upshot though is you could still bootstrap with a single command (assuming you have the decryption key).

I'm open to other ideas as well.

That makes sense, although that change would make the bootstrap feature potentially less useful for other use cases. (Like restoring all configs with a single borgmatic command.) So here are a few different ideas on how to address this: * Add a configuration option for disabling the automatic storing of configuration files altogether. This would prevent the `bootstrap` action from working, but it'd avoid leaking any information across repositories. * Or.. Add a configuration option for restricting automatic storing of configuration files to only the repositories used in those configuration files. This would make the `bootstrap` action less useful, but it'd still work. And a user would have to intentionally opt in to this. * Or.. Optionally encrypt configuration files as stored in each repository with a key specified on the `borgmatic config bootstrap` command-line. I'm not a huge fan of this idea though, as: 1. It's encrypting something already store in an encrypted repository, and 2. borgmatic would have to get into the business of encryption, which right now it 100% farms out to Borg. The upshot though is you could still bootstrap with a single command (assuming you have the decryption key). I'm open to other ideas as well.
Author

I would be happy about the first option over not having any choice at all. In my use case, automatic bootstrapping is not a key issue after system failure. Essentially, the system can be built from scratch and only data needs to be recovered afterwards.

For the second, I'm not familiar enough about the system to tell whether the effort is worth it, but it sounds ideal.

It should be opt-in in any case, I agree.

The third option seems too complicated, brittle and inelegant.

I would be happy about the first option over not having any choice at all. In my use case, automatic bootstrapping is not a key issue after system failure. Essentially, the system can be built from scratch and only data needs to be recovered afterwards. For the second, I'm not familiar enough about the system to tell whether the effort is worth it, but it sounds ideal. It should be opt-in in any case, I agree. The third option seems too complicated, brittle and inelegant.
Collaborator

I discussed with witten that I'll implement the first option when I'm free from other GSoC tasks.

I discussed with witten that I'll implement the first option when I'm free from other GSoC tasks.
witten added the
design finalized
label 2023-07-31 20:11:11 +00:00
witten referenced this issue from a commit 2023-07-31 21:04:16 +00:00
Owner

Implemented in main by @diivi via a new store_config_files option that can be set to false. This will be part of the next release! Thanks again for the ticket.

Implemented in main by @diivi via a new `store_config_files` option that can be set to `false`. This will be part of the next release! Thanks again for the ticket.
Owner

Just released in borgmatic 1.8.1!

Just released in borgmatic 1.8.1!
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#725
No description provided.