Unmount FS before backup to avoid failure due to lock #845
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#845
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?
Hi! I use systemd to regularly backup the system with the help of bormgatic.
Sometimes I mount it and sometimes forget to unmount :/ This, of course, blocks from running next backups.
Would you help to find out how to forcedly unmount the FS before starting the backup procedure? Eg via hook.
Additionally, it may be added to the configuration as an option: if mounted:
What do you think?
Unmount FS before backupto Unmount FS before backup to avoid failure due to lockI haven't tested it, but you might be able to just do something like:
I would recommend trying it both with the filesystem mounted and unmounted to make sure it doesn't error.
Or if you'd prefer you can put that in
before_actions
or evenbefore_everything
. See the hook documentation for more information.As for a configuration option, I'm not necessarily averse to it, but it does seem a little specialized and I'm not sure how it would figure out which mount point paths to use (unless that's also part of the configuration). I'd recommend trying the hook approach first and seeing how that goes!
Hi! The command should rather look like:
But, in case it is already unmounted it will return non-zero exit status, what will influence negatively on the next steps of borgmatic process.
UPD: my suggestion:
I generally don't recommend running borgmatic from borgmatic, just to avoid the risk of infinite recursion. And
borgmatic umount
is really a thin wrapper aroundumount
, so you're not losing much of anything by runningumount
directly.But to prevent umount's non-zero exit status from causing an error when nothing is mounted, you can try this:
should be:
Yes,
sudo
would be needed if you're running as a non-root user. But be aware thatsudo
can prompt for a password, which would be problematic if used non-interactively.strangely, this didn't work:
Are you running borgmatic as the root user? If so, then you don't need
sudo
at all.I run borgmatic as a root, but it doesn't work without sudo the same.
This is my borgmatic.service unit file
My guess is that some of the systemd security settings (something from
LockPersonality
toReadWritePaths
) are interfering with yourumount
command. So my recommendation is to try removing some or all of these settings and then reloading the systemd daemon (systemctl daemon-reload
) to make those changes take effect.