Support for multiple repository root directories #2

Open
opened 2024-06-07 19:49:22 +00:00 by lingling · 1 comment
Owner

Currently only one backup per host is possible. The root folder for the backups is set in borg_server_repo_root.

But it is desirable to make at least a second backup, e. g. to a temporary connected external drive.

The scripts borgctl and backup.sh need to be aware of the repository currently used.

Maybe I can set one repository as default in the scripts and another ones as fallback. When the script is called without any repository then the default repository is used and if the script is called with a path for a repository, it is checked if it is existant.

Currently only one backup per host is possible. The root folder for the backups is set in `borg_server_repo_root`. But it is desirable to make at least a second backup, e. g. to a temporary connected external drive. The scripts `borgctl` and `backup.sh` need to be aware of the repository currently used. Maybe I can set one repository as default in the scripts and another ones as fallback. When the script is called without any repository then the default repository is used and if the script is called with a path for a repository, it is checked if it is existant.
lingling added this to the 2.0.0 milestone 2024-06-10 10:44:43 +00:00
Author
Owner

Following tasks would need to be done. Either borg_server_repo_root need to be a mapping with multiple entries or another variable borg_server_repo_root_additional is needed. A mapping could look like this:

borg_server_repo_roots:
    - path: /media/backup
      optional: false
    - path: /mnt/backup
      optional: true

Then everything including the repo root variable need to be called multiple times.

  1. Server: Create or modify repo root folder
    forgejo.lingnet.internal/ansible-roles/borg@5acb7842af/tasks/configure.yaml (L20-L31)
  2. Server: Create or modify borg repo folder
    forgejo.lingnet.internal/ansible-roles/borg@5acb7842af/tasks/configure.yaml (L33-L41)
  3. Borg repo Initialization
    forgejo.lingnet.internal/ansible-roles/borg@5acb7842af/tasks/configure.yaml (L156-L198)
  4. The backup script need to be aware of the currently used repository. Especially the BORG_REPO environment variable need to be modified to take a variable. Currently it does just take a static defined variable of one repo url.
    forgejo.lingnet.internal/ansible-roles/borg@5acb7842af/templates/borg-environment.j2 (L15)
    This also does imply that some argument interpreting for the script would be necessary. Another solution could be to deploy multiple scripts.
  5. The checks in tasks/main.yaml need to check the config for multi repo root directories.
  6. It is necessary to decide which folder should be automated. Also it is necessary that the systemd service(s) calls the backup script with the right arguments to backup to the right remote repository.
  7. At least not-automated scripts need to be callable on demand from a playbook.
  8. As this result in multiple repositories the SSH Configuration on the server need to accept the additional repositories. This can be done by setting --restrict-to-repository multiple times for borg serve. This is also addressed in #8.

In summary this change does need a bigger refactoring of the role.

Following tasks would need to be done. Either `borg_server_repo_root` need to be a mapping with multiple entries or another variable `borg_server_repo_root_additional` is needed. A mapping could look like this: ```yaml borg_server_repo_roots: - path: /media/backup optional: false - path: /mnt/backup optional: true ``` Then everything including the repo root variable need to be called multiple times. 1. Server: Create or modify repo root folder https://forgejo.lingnet.internal/ansible-roles/borg/src/commit/5acb7842afef0d48dc38481ca578d6444c430153/tasks/configure.yaml#L20-L31 2. Server: Create or modify borg repo folder https://forgejo.lingnet.internal/ansible-roles/borg/src/commit/5acb7842afef0d48dc38481ca578d6444c430153/tasks/configure.yaml#L33-L41 3. Borg repo Initialization https://forgejo.lingnet.internal/ansible-roles/borg/src/commit/5acb7842afef0d48dc38481ca578d6444c430153/tasks/configure.yaml#L156-L198 4. The backup script need to be aware of the currently used repository. Especially the `BORG_REPO` environment variable need to be modified to take a variable. Currently it does just take a static defined variable of one repo url. https://forgejo.lingnet.internal/ansible-roles/borg/src/commit/5acb7842afef0d48dc38481ca578d6444c430153/templates/borg-environment.j2#L15 This also does imply that some argument interpreting for the script would be necessary. Another solution could be to deploy multiple scripts. 5. The checks in `tasks/main.yaml` need to check the config for multi repo root directories. 6. It is necessary to decide which folder should be automated. Also it is necessary that the systemd service(s) calls the backup script with the right arguments to backup to the right remote repository. 7. At least not-automated scripts need to be callable on demand from a playbook. 8. As this result in multiple repositories the SSH Configuration on the server need to accept the additional repositories. This can be done by setting `--restrict-to-repository` multiple times for [borg serve](https://borgbackup.readthedocs.io/en/stable/usage/serve.html). This is also addressed in #8. In summary this change does need a bigger refactoring of the role.
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
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
ansible-roles/borg#2
No description provided.