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/restic: init #38948
nixos/restic: init #38948
Conversation
}; | ||
repo = mkOption { | ||
type = types.str; | ||
default = "sftp:backup@prism.r:/backups/${config.name}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all nixos users are connect to retiolum
yet. Also the machine would run out of storage.
}; | ||
initialize = mkOption { | ||
type = types.bool; | ||
default = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this option idempotent? Can the backup run multiple times when initialize = true;
without breaking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
}; | ||
passwordFile = mkOption { | ||
type = types.str; | ||
default = toString <secrets/restic-password>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have no convention on <secrets>
in nix path yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should document the "stockholm way" somewhere ;)
f90b6c6
to
9404713
Compare
#! ${pkgs.bash}/bin/bash | ||
${resticCmd} snapshots || ${resticCmd} init | ||
''); | ||
ExecStart = pkgs.writeDash "rustic-${plan.name}" ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be writeScript
''); | ||
ExecStart = pkgs.writeDash "rustic-${plan.name}" ( | ||
"#! ${pkgs.bash}/bin/bash\n" + | ||
concatMapStringsSep "\n" (dir: "${resticCmd} backup ${dir}") plan.dirs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (readability):
''
#! ${pkgs.bash}/bin/bash
${concatMapStringsSep "\n" (dir: "${resticCmd} backup ${dir}") plan.dirs}
''
9404713
to
7767fea
Compare
tested with: {...}: {
services.restic.backups.mybackup = {
directories = ["/tmp/foo"];
repository = "/tmp/backup";
passwordFile = "/etc/nixos/secrets/restic-password";
initialize = true;
};
} |
cc @fd0 |
''; | ||
example = "sftp:backup@192.168.1.100:/backups/${name}"; | ||
}; | ||
directories = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you backup single files? I think a name like paths
would be more appropriate.
restartIfChanged = false; | ||
serviceConfig = { | ||
Type = "oneshot"; | ||
ExecStart = map (dir: "${resticCmd} backup ${dir}") backup.directories; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't restic backup some/file other/file
allowed?
type = types.listOf types.str; | ||
default = []; | ||
description = '' | ||
Extra arguments to append to the restic command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is "appended" (not really) to all restic commands (init
and backup
), I think it's impossible to add backup-only options like --exclude-caches
. That should however be possible.
As it was done for the borg service, I suggest adding extraInitArgs
and extraBackupArgs
options.
systemd.services = | ||
mapAttrs' (name: backup: | ||
let | ||
extraArguments = concatMapStringsSep " " (arg: "-o ${arg}") backup.extraArguments; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since extraArguments
is mapped to -o
I think this should be mentioned in the description and the option renamed to extraOptions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be each key only specified once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know about that but when reading extraArguments
I think of something like restic --extra-arg
.
Hu? I'm late to the party, is there anything in particular you'd like me to comment on @Mic92? |
@fd0 this was more meant as a general notification. Sometimes upstream developer have valuable input. |
Cool, thanks for letting me know! NixOS is on my list of things to try :) |
I'm currently using this to backup my machines. feedback is appreciated, it mostly just satisfies my use-cases.