Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include last successful archive in borg info #4047

Closed
varac opened this issue Aug 14, 2018 · 11 comments
Closed

Include last successful archive in borg info #4047

varac opened this issue Aug 14, 2018 · 11 comments

Comments

@varac
Copy link

varac commented Aug 14, 2018

I need to integrate a check for successful backups in our monitoring system.

There's nagios-plugin-check_borg but it lists it limitation in the README.md:

I don't know how to exclude checkpoints in borg list in combination with --format='{time}{NUL}'.

If would be nice if borg info could contain the details (time, archive name) of the last successful backup (excluding checkpoint archves).

@ThomasWaldmann
Copy link
Member

One can easily recognize checkpoints by their name, so it seems this is just one filter missing in that plugin.

borg info only knows 2 scopes:

  • repo (giving some general information about the repository, not looking at archives)
  • single archive (giving infos about that single archive)

So this does not seem in-scope of the current implementation.

Some latest archive being not a checkpoint is not necessarily a sufficient condition for a "successful backup", it just means that that backup reached the normal end of execution. But there could be still warnings in the log / borg exiting with rc=1.

One also needs to consider the prefix:

  • system-2018-08-13.checkpoint
  • home-2018-08-13
  • system-2018-08-14.checkpoint
  • home-2018-08-15

You see: last backup was not a checkpoint, but still the system backups somehow never got finished.

I'm closing this, it seems like this is rather something for a on-top-of-borg management tool.

@varac
Copy link
Author

varac commented Aug 16, 2018

Can anybody at least help me with the --glob-archive syntax ?
I'm trying to exclude checkpoints like this:

borg list --glob-archives 're:(?!.*checkpoint).*'  $REPOSITORY

But this doesn't show anything even if there are successful archives.

I tried the same re in ipython3 and there it seems to work:

In [12]: re.search("^(?!.*checkpoint)", 'archive.checkpoint')

In [13]: re.search("^(?!.*checkpoint)", 'archive')
Out[13]: <_sre.SRE_Match object; span=(0, 0), match=''>

@ThomasWaldmann
Copy link
Member

IIRC it is just globbing (like on the shell, or with sh:), not regex matching.

You can not give a re: or sh: prefix there.

@varac
Copy link
Author

varac commented Aug 16, 2018

for the record, I now use this to show the last successful backup timestamp in the repo:

borg list --sort timestamp  --format '{time}{TAB}{name}{NEWLINE}'  $REPOSITORY  | grep -v '\.checkpoint$' | tail -1 |  cut -f 1

@ThomasWaldmann
Copy link
Member

@varac guess that works if you have only 1 backup series in the repo. if you do separate backups into 1 repo, you'ld need to check some prefix or so.

@varac
Copy link
Author

varac commented Sep 20, 2018

if you do separate backups into 1 repo, you'ld need to check some prefix or so.

That or even better: borg should show the last successful backup for all backups in the repo, which than can get easily grepped for the specific backup in question.

@witten
Copy link
Contributor

witten commented Oct 13, 2019

I'm not exactly proud of myself here, but this appears to exclude checkpoint archives:

borg list --glob-archives "*[!.][!c][!h][!e][!c][!k][!p][!o][!i][!n][!t]" ...

@jdchristensen
Copy link
Contributor

@witten I don't think that does what you want. For example, it won't list any archive whose name ends in "t". And it won't list any archive whose name is shorter than 11 characters. The earlier grep method seems better.

@witten
Copy link
Contributor

witten commented Oct 16, 2019

Right you are. 😄

The reason the grep approach (which actually has the distinct advantage of working, as you point out) isn't so great for me is that I can't combine it with many of borg list's built-in filters. For instance, borg list ... --last 2 | grep -v '\.checkpoint$' won't work correctly, because the grep filter is applied after the last, so I may get an unexpected number of results (0, 1, or 2). Sure, I can work around that with shell commands, but then I lose the ability to use Borg's own filters. Additionally, the same shell commands most certainly won't work with and without --json.

This may not sound like a big loss, but I'm trying to provide an "on-top-of-borg management tool" (as @ThomasWaldmann suggests), and so it'd make for an odd user experience to say to users: If you want to filter out checkpoints, then you lose the ability to use other archive filters / JSON at the same time!

I know this ticket is already closed, but I think what would be really great is a --no-checkpoints archive filter in Borg, or perhaps a way to do that with --glob-archives.

@ThomasWaldmann
Copy link
Member

@witten we already have a --consider-part-files options to steer whether part files are considered in some operations or not.

Could imagine that we add a --consider-checkpoints, please open a new ticket to discuss that.

@witten
Copy link
Contributor

witten commented Oct 19, 2019

Good idea. Filed #4788.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants