syncthing: add proper versioning
This commit is contained in:
parent
80642ddf99
commit
592901ea2c
2 changed files with 52 additions and 12 deletions
|
@ -18,7 +18,7 @@ let
|
|||
fsWatcherEnabled = folder.watch;
|
||||
fsWatcherDelayS = folder.watchDelay;
|
||||
ignorePerms = folder.ignorePerms;
|
||||
versioning = optionalAttrs folder.versioning.enable { type = "simple"; params.keep = toString folder.versioning.keep; };
|
||||
versioning = folder.versioning;
|
||||
}) (filterAttrs (
|
||||
_: folder:
|
||||
folder.enable
|
||||
|
@ -221,17 +221,57 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
versioning = {
|
||||
enable = mkEnableOption ''
|
||||
simple versioning, see https://docs.syncthing.net/users/versioning.html#simple-file-versioning
|
||||
'';
|
||||
keep = mkOption {
|
||||
type = types.int;
|
||||
default = 5;
|
||||
versioning = mkOption {
|
||||
default = null;
|
||||
description = ''
|
||||
The number of old versions to keep, per file.
|
||||
how to keep changed/deleted files with syncthing.
|
||||
there are 4 different types of versioning with different parameters
|
||||
see https://docs.syncthing.net/users/versioning.html#simple-file-versioning
|
||||
'';
|
||||
example = [
|
||||
{
|
||||
versioning = {
|
||||
type = "simple";
|
||||
params.keep = "10";
|
||||
};
|
||||
}
|
||||
{
|
||||
versioning = {
|
||||
type = "trashcan";
|
||||
params.cleanoutDays = "1000";
|
||||
};
|
||||
}
|
||||
{
|
||||
versioning = {
|
||||
type = "staggered";
|
||||
params = {
|
||||
cleanInterval = "3600";
|
||||
maxAge = "31536000";
|
||||
versionsPath = "/syncthing/backup";
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
versioning = {
|
||||
type = "external";
|
||||
params.versionsPath = pkgs.writers.writeBash "backup" ''
|
||||
folderpath="$1"
|
||||
filepath="$2"
|
||||
rm -rf "$folderpath/$filepath"
|
||||
'';
|
||||
};
|
||||
}
|
||||
];
|
||||
type = with types; nullOr (submodule {
|
||||
options = {
|
||||
type = mkOption {
|
||||
type = enum [ "external" "simple" "staggered" "trashcan" ];
|
||||
};
|
||||
params = mkOption {
|
||||
type = attrsOf (either str path);
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
rescanInterval = mkOption {
|
||||
|
|
Loading…
Reference in a new issue