From c12c47caceb93bc1ee6a41e298887b0cb8de759b Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 16 Oct 2019 10:24:58 -0700 Subject: [PATCH] Fix "borgmatic list --successful" with a slightly better heuristic for listing successful (non-checkpoint) archives. --- NEWS | 4 ++++ borgmatic/borg/list.py | 5 +++-- docs/how-to/monitor-your-backups.md | 12 +++++++++--- setup.py | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 89d9884..97b952e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +1.3.26 + * #224: Fix "borgmatic list --successful" with a slightly better heuristic for listing successful + (non-checkpoint) archives. + 1.3.25 * #223: Dead man's switch to detect when backups start failing silently, implemented via healthchecks.io hook integration. See the documentation for more information: diff --git a/borgmatic/borg/list.py b/borgmatic/borg/list.py index aa831e5..854ceff 100644 --- a/borgmatic/borg/list.py +++ b/borgmatic/borg/list.py @@ -6,8 +6,9 @@ from borgmatic.execute import execute_command logger = logging.getLogger(__name__) -# A hack to convince Borg to exclude archives ending in ".checkpoint". -BORG_EXCLUDE_CHECKPOINTS_GLOB = '*[!.][!c][!h][!e][!c][!k][!p][!o][!i][!n][!t]' +# A hack to convince Borg to exclude archives ending in ".checkpoint". This assumes that a +# non-checkpoint archive name ends in a digit (e.g. from a timestamp). +BORG_EXCLUDE_CHECKPOINTS_GLOB = '*[0123456789]' def list_archives(repository, storage_config, list_arguments, local_path='borg', remote_path=None): diff --git a/docs/how-to/monitor-your-backups.md b/docs/how-to/monitor-your-backups.md index dda031b..282e797 100644 --- a/docs/how-to/monitor-your-backups.md +++ b/docs/how-to/monitor-your-backups.md @@ -129,9 +129,15 @@ output only shows up at the console, and not in syslog. ### Successful backups `borgmatic list` includes support for a `--successful` flag that only lists -successful (non-checkpoint) backups. Combined with a built-in Borg flag like -`--last`, you can list the last successful backup for use in your monitoring -scripts. Here's an example combined with `--json`: +successful (non-checkpoint) backups. This flag works via a basic heuristic: It +assumes that non-checkpoint archive names end with a digit (e.g. from a +timestamp), while checkpoint archive names do not. This means that if you're +using custom archive names that do not end in a digit, the `--successful` flag +will not work as expected. + +Combined with a built-in Borg flag like `--last`, you can list the last +successful backup for use in your monitoring scripts. Here's an example +combined with `--json`: ```bash borgmatic list --successful --last 1 --json diff --git a/setup.py b/setup.py index de307d5..f1dae30 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.3.25' +VERSION = '1.3.26' setup(