syncthing: add proper versioning

This commit is contained in:
Ingolf Wagner 2019-11-05 22:39:57 +01:00
parent 80642ddf99
commit 592901ea2c
Signed by: palo
GPG key ID: 76BF5F1928B9618B
2 changed files with 52 additions and 12 deletions

View file

@ -18,7 +18,7 @@ let
fsWatcherEnabled = folder.watch; fsWatcherEnabled = folder.watch;
fsWatcherDelayS = folder.watchDelay; fsWatcherDelayS = folder.watchDelay;
ignorePerms = folder.ignorePerms; ignorePerms = folder.ignorePerms;
versioning = optionalAttrs folder.versioning.enable { type = "simple"; params.keep = toString folder.versioning.keep; }; versioning = folder.versioning;
}) (filterAttrs ( }) (filterAttrs (
_: folder: _: folder:
folder.enable folder.enable
@ -221,17 +221,57 @@ in {
''; '';
}; };
versioning = { versioning = mkOption {
enable = mkEnableOption '' default = null;
simple versioning, see https://docs.syncthing.net/users/versioning.html#simple-file-versioning
'';
keep = mkOption {
type = types.int;
default = 5;
description = '' 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 { rescanInterval = mkOption {