Have a hook firing when the process exits because of CTRL+C. #434
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#434
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I'm in the process of setting up various backups using BorgMatic in a setup where there's one server hosting BorgMatic and fetching contents using SSHFS from remote systems. Additionally I'm testing backing up Postgres file based by issuing
pg_start_backup
andpg_stop_backup
. All of my use cases have in common that there's some state handling necessary: E.g. before a backup some snapshots need to be taken using BTRFS/ZFS, some dirs need to be mounted,pg_start_backup
called etc. A corresponding hookafter_backup
oron_error
are available already to clean things up properly.Though, from my understanding those only fire in case everything works and finishes as expected. But during my setup I need to test a lot of things and am simply aborting backups soon after they have started to test further. Waiting for the backup to finish would simply take too long and is wasted time. The problem seems to be that when I simply kill the process using STRG+C, neither
after_backup
noron_error
fire, so things are not cleaned up.I try to take that into account when executing the backup again by e.g. first unmounting probably already mounted dirs, deleting prbably already available snapshots etc. But that makes the
before_backup
-hook more complex than necessary in theory and requires to start a new backup. Without that a snapshots might be kept around far longer as necessary or Postgres would stay in backup mode.Having CTRL+C catched and mapped to some hook like
on_abort|exit|kill|...
or alike would allow me to run the same cleanup likeafter_backup
oron_error
in theory.Thanks for considering!
Environment
borgmatic version: 1.5.15
borgmatic installation method: PIP, system wide
Borg version: 1.1.16
Python version: 3.8.10
operating system and version: Ubuntu 20.04
What about simply firing
on_error
when ctrl-C is pressed? Would that work for you use case? Or do you really need a separate hook with different logic?I'm closing this one for now due to inactivity, but I'd be happy to open it up again if you have further thoughts. Thank you!