SIGTERM is not terminating borgmatic
What I'm trying to do and why
I am using borgmatic on debian/testing. There borgmatic is started by a systemd timer and service. Stopping or restarting the service while borgmatic is creating an archive doesn't work.
Steps to reproduce (if a bug)
- Create multiple configuration files in /etc/borgmatic.d/
(it looks like it can also be 1 configuration file with multiple repositories)
/usr/bin/borgmatic --verbosity 1
- While borgmatic is working (prune/create/...) on the first repository, stop it from an other terminal with
pkill --signal TERM borgmatic.
Actual behavior (if a bug)
The work on the first repository is stopped, but borgmatic continues on the next repository.
Expected behavior (if a bug)
borgmatic should stop the current running action (of borg) and then terminate.
Other notes / implementation ideas
The signal SIGTERM indicates for a process that it needs to be stopped. The process is allowed to clean up it's environment (release locks) but then should stop as soon as possible. It should not start new long lasting actions.
It looks like the method
_handle_signal only propagates the SIGTERM to the subprocesses, but the current process (borgmatic) can just continue (with the next repository). This is not correct. Borgmatic should stop as well.
borgmatic version: [1.5.20]
borgmatic installation method: [Debian package]
Borg version: [borg 1.2.0]
Python version: [Python 3.9.12]
Database version (if applicable): [N/A]
operating system and version: [debian testing]
Good catch! Looks like it's indeed a bug based on the code, although I haven't yet verified with a local repro. Thank you for filing this.
EDIT: Got a local repro now.
Deleting a branch is permanent. It CANNOT be undone. Continue?