discussion: using different repos, dependent on network conditions #626
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#626
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?
note: this is more of a discussion-post. I'm not expecting this to be fixed or even truly borgmatic's problem to solve, but hoping this might be useful to others (eg both #205 or my previous #419 are nicely searchable).
What I'm trying to do and why
I want a local repo (on a 2nd SSD in my laptop) to be used as the only repository in "some cases", and otherwise I want the remote repositories to be used and not bother with the local repo. The "some cases" here is: if I'm on my home wifi network (a particular SSID) then I know I have a great internet connection, or if that's not achievable then simply making the switch when there's outright no network connectivity.
Other notes / implementation ideas
I think the answer is that you'd need👍👍 to...
config.yaml
into two: one for "over-network" backups, one for "local-backups"ExecStart
CLI line can be distinct on both (for differing-c
config args)I'm just not sure what kind of wonky situation would happen if "local-backups" was running and then you switched networks (or say your internet was out, backup started, but now internet comes back on, and then the "over-network" schedule starts)... would both try to run and make your machine unusable? TODO here is for me to figure out if systemd has a way to make units mutually exclusive.
Thanks for filing this.. Discussion tickets are an excellent use of this issue tracker!
Have you seen the documentation on intermittent backups? You could write a
before_backup
shell script that runs any logic you want (including checking for a particular wifi SSID) and returns an exit code of 75 to indicate that configuration file's backups should be skipped.With this approach, you'd still need two configuration files as you described. But you would only need a single borgmatic service unit / timer, and the backups would run serially so you wouldn't need to worry about making them mutually exclusive. (Although you wouldn't get any of the benefits of running them in parallel, either).
perfect, you're right, thanks for the reply! For some reason I was imagining the
before_backup
logic inside of systemd rather than a config value of borgmatic (which makes no sense, because I've usedbefore_backup
before for the battery-capacity check in #419).Anyway, yes this is perfect and I've broken out my configs and tested this works perfectly! Here's a diff if anyone's sufficiently motivated - it's of course specific to my machine/dotfile-setup but I think the two "known fast SSID"-scripts (thin
nmcli
wrappers) and the example of the YAML split-up, all in one place might be helpful.There's one thing I have left to figure out: prevent actual serial running (since this is meant as a round-robin, pick one destination, not every-single-one). Example: say one backup starts correctly and then half-way through the state changes (eg: offline backsup starts and then we get onto a good SSID half-way through the backup) then I wouldn't want the online backup to start immediately afterwards. Instead I'd rather wait until the next systemd timer schedule tries to run. Otherwise these backups take forever (slowing down my computer).
I'll close this for now, because this is sufficient, but feel free to reopen/comment for thoughts here! My only thought is to add another hook that somehow figures out if there's a recent successful backup somewhere :| ... feels ugly.
tl;dr for each systemd invokation, have just one borgmatic-config get to a started-state (ie: get beyond the pre/before-hooks successfully), rather than all configs get tried.
Glad to hear that approach works for you!
As for preventing serial running.. It might be kind of hacky, but you could write another
before_backup
script for the online backup configuration file that checks the last backup time of the offline repository and, if too recent, exits with code 75.I don't normally recommend running borgmatic from borgmatic, but maybe something like:
Something similar could also be done with Borg directly.