From d2714cb706c45ccc05f4890bedfa2d97e4e194ee Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 26 Mar 2025 09:53:52 -0700 Subject: [PATCH 1/4] Fix an error in the systemd credential hook when the credential name contains a "." chararcter (#1044). --- NEWS | 2 ++ borgmatic/hooks/credential/systemd.py | 2 +- tests/unit/hooks/credential/test_systemd.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index fd41e40c..3ae8b8e6 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ https://torsion.org/borgmatic/docs/how-to/backup-your-databases/#containers * #1037: Fix an error with the "extract" action when both a remote repository and a "working_directory" are used. + * #1044: Fix an error in the systemd credential hook when the credential name contains a "." + chararcter. 1.9.14 * #409: With the PagerDuty monitoring hook, send borgmatic logs to PagerDuty so they show up in the diff --git a/borgmatic/hooks/credential/systemd.py b/borgmatic/hooks/credential/systemd.py index 1de245a3..9cce0d7b 100644 --- a/borgmatic/hooks/credential/systemd.py +++ b/borgmatic/hooks/credential/systemd.py @@ -5,7 +5,7 @@ import re logger = logging.getLogger(__name__) -CREDENTIAL_NAME_PATTERN = re.compile(r'^\w+$') +CREDENTIAL_NAME_PATTERN = re.compile(r'^[\w.-]+$') def load_credential(hook_config, config, credential_parameters): diff --git a/tests/unit/hooks/credential/test_systemd.py b/tests/unit/hooks/credential/test_systemd.py index 603c8569..32133883 100644 --- a/tests/unit/hooks/credential/test_systemd.py +++ b/tests/unit/hooks/credential/test_systemd.py @@ -42,12 +42,12 @@ def test_load_credential_reads_named_credential_from_file(): '/var' ) credential_stream = io.StringIO('password') - credential_stream.name = '/var/mycredential' + credential_stream.name = '/var/borgmatic.pw' builtins = flexmock(sys.modules['builtins']) - builtins.should_receive('open').with_args('/var/mycredential').and_return(credential_stream) + builtins.should_receive('open').with_args('/var/borgmatic.pw').and_return(credential_stream) assert ( - module.load_credential(hook_config={}, config={}, credential_parameters=('mycredential',)) + module.load_credential(hook_config={}, config={}, credential_parameters=('borgmatic.pw',)) == 'password' ) From 79e4e089eeffd097472c2ccb8aacc03a54ba0fba Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 26 Mar 2025 09:57:53 -0700 Subject: [PATCH 2/4] Fix typo in NEWS (#1044). --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3ae8b8e6..df2261d8 100644 --- a/NEWS +++ b/NEWS @@ -17,7 +17,7 @@ * #1037: Fix an error with the "extract" action when both a remote repository and a "working_directory" are used. * #1044: Fix an error in the systemd credential hook when the credential name contains a "." - chararcter. + character. 1.9.14 * #409: With the PagerDuty monitoring hook, send borgmatic logs to PagerDuty so they show up in the From 520fb78a00fb4e736e71a6973c9e439f36a5376b Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 26 Mar 2025 11:39:16 -0700 Subject: [PATCH 3/4] Clarify Btrfs documentation: borgmatic expects subvolume mount points in "source_directories" (#1043). --- docs/how-to/snapshot-your-filesystems.md | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/how-to/snapshot-your-filesystems.md b/docs/how-to/snapshot-your-filesystems.md index 8dd8bad5..018e6553 100644 --- a/docs/how-to/snapshot-your-filesystems.md +++ b/docs/how-to/snapshot-your-filesystems.md @@ -148,9 +148,9 @@ feedback](https://torsion.org/borgmatic/#issues) you have on this feature. #### Subvolume discovery -For any read-write subvolume you'd like backed up, add its path to borgmatic's -`source_directories` option. Btrfs does not support snapshotting read-only -subvolumes. +For any read-write subvolume you'd like backed up, add its mount point path to +borgmatic's `source_directories` option. Btrfs does not support snapshotting +read-only subvolumes. New in version 1.9.6 Or include the mount point as a root pattern with borgmatic's `patterns` or `patterns_from` @@ -161,27 +161,27 @@ includes the snapshotted files in the paths sent to Borg. borgmatic is also responsible for cleaning up (deleting) these snapshots after a backup completes. borgmatic is smart enough to look at the parent (and grandparent, etc.) -directories of each of your `source_directories` to discover any subvolumes. -For instance, let's say you add `/var/log` and `/var/lib` to your source -directories, but `/var` is a subvolume. borgmatic will discover that and -snapshot `/var` accordingly. This also works even with nested subvolumes; +directories of each of your `source_directories` to discover any subvolumes. For +instance, let's say you add `/var/log` and `/var/lib` to your source +directories, but `/var` is a subvolume mount point. borgmatic will discover that +and snapshot `/var` accordingly. This also works even with nested subvolumes; borgmatic selects the subvolume that's the "closest" parent to your source directories. New in version 1.9.6 When using [patterns](https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-help-patterns), the initial portion of a pattern's path that you intend borgmatic to match -against a subvolume can't have globs or other non-literal characters in it—or it -won't actually match. For instance, a subvolume of `/var` would match a pattern -of `+ fm:/var/*/data`, but borgmatic isn't currently smart enough to match -`/var` to a pattern like `+ fm:/v*/lib/data`. +against a subvolume mount point can't have globs or other non-literal characters +in it—or it won't actually match. For instance, a subvolume mount point of +`/var` would match a pattern of `+ fm:/var/*/data`, but borgmatic isn't +currently smart enough to match `/var` to a pattern like `+ fm:/v*/lib/data`. -Additionally, borgmatic rewrites the snapshot file paths so that they appear -at their original subvolume locations in a Borg archive. For instance, if your -subvolume exists at `/var/subvolume`, then the snapshotted files will appear +Additionally, borgmatic rewrites the snapshot file paths so that they appear at +their original subvolume locations in a Borg archive. For instance, if your +subvolume is mounted at `/var/subvolume`, then the snapshotted files will appear in an archive at `/var/subvolume` as well—even if borgmatic has to mount the -snapshot somewhere in `/var/subvolume/.borgmatic-snapshot-1234/` to perform -the backup. +snapshot somewhere in `/var/subvolume/.borgmatic-snapshot-1234/` to perform the +backup. With Borg version 1.2 and earlierSnapshotted files are instead stored at a path dependent on the From 486bec698d44b2dd560983f990e8c595683a85a7 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 26 Mar 2025 22:13:30 -0700 Subject: [PATCH 4/4] Add "key import" to reference documentation (#345). --- docs/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Dockerfile b/docs/Dockerfile index c3279570..afa3457d 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -4,7 +4,7 @@ COPY . /app RUN apk add --no-cache py3-pip py3-ruamel.yaml py3-ruamel.yaml.clib RUN pip install --break-system-packages --no-cache /app && borgmatic config generate && chmod +r /etc/borgmatic/config.yaml RUN borgmatic --help > /command-line.txt \ - && for action in repo-create transfer create prune compact check delete extract config "config bootstrap" "config generate" "config validate" export-tar mount umount repo-delete restore repo-list list repo-info info break-lock "key export" "key change-passphrase" borg; do \ + && for action in repo-create transfer create prune compact check delete extract config "config bootstrap" "config generate" "config validate" export-tar mount umount repo-delete restore repo-list list repo-info info break-lock "key export" "key import" "key change-passphrase" borg; do \ echo -e "\n--------------------------------------------------------------------------------\n" >> /command-line.txt \ && borgmatic $action --help >> /command-line.txt; done RUN /app/docs/fetch-contributors >> /contributors.html