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

nixos/borgbackup: Add a persistent option #123434

Closed
wants to merge 1 commit into from

Conversation

blargg
Copy link
Contributor

@blargg blargg commented May 18, 2021

Persistent starts the backup service on power on if it was missed while
the system was powered down, for example.

Motivation for this change

Adds an option to make a backup job start on boot if it was missed during power off. This is useful for backups on personal machines where you might have the machine off during the normally scheduled backup.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS (n/a)
    • other Linux distributions (n/a)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/) (tested the service to make sure it runs)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@blargg
Copy link
Contributor Author

blargg commented May 18, 2021

This version follows along with how nix-gc allows for these parameters

persistent = mkOption {
.

@SuperSandro2000 SuperSandro2000 changed the title (nixos/borgbackup): Add a persistent option. nixos/borgbackup: Add a persistent option May 18, 2021
Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow our commit naming guide: nixos/borgbackup: Add a persistent option.

Persistent starts the backup service on power on if it was missed while
the system was powered down, for example.
@blargg
Copy link
Contributor Author

blargg commented May 20, 2021

Updated the formatting and the commit name.

@blargg
Copy link
Contributor Author

blargg commented May 22, 2021

Not sure if we want to act on the following as part of this PR, but will mention this here either way:
Since we add the ability to start on boot, it's a lot more likely that we run into the case where you try to back up to a remote server before the network starts up, causing the run to fail.

It seems like this is fixable by adding

wants = [ "network-online.target" ];
after = [ "network-online.target" ];

to either the timer or service. I think we could automatically detect remote usage by checking for "@" in the string for the repo, and possibly provide a setting to override.

@Stunkymonkey
Copy link
Contributor

there is a previous PR #75056. I would prefer calling it persistentTimer, to point to the relationship with the timer unit (like @mweinelt suggested).

The rest looks fine to me.

@@ -98,6 +98,13 @@ let
inherit (cfg) startAt;
};

mkBackupTimers = name: cfg:
nameValuePair "borgbackup-job-${name}" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a description would be nice as well

@Stunkymonkey
Copy link
Contributor

@mweinelt is setting the default value to true desirable?

@Stunkymonkey
Copy link
Contributor

fixed in #153346

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

Successfully merging this pull request may close these issues.

None yet

3 participants