rclone sync redo

This commit is contained in:
Chaos 2023-03-19 11:44:27 +00:00
parent d0583ddb89
commit 7de328e48f
No known key found for this signature in database
4 changed files with 33 additions and 27 deletions

View file

@ -15,27 +15,33 @@
{
source = "StorageBox:Backups";
dest = "B2-Chaos-Backups:";
id = "chaos_b2_backups";
}
{
source = "StorageBox:Photos";
dest = "B2-Chaos-Photos:";
id = "chaos_b2_photos";
}
{
source = "StorageBox:Music";
dest = "B2-Chaos-Music:";
id = "chaos_b2_music";
}
# Pheonix System's B2
{
source = "StorageBox:Backups";
dest = "B2-Phoenix-Cryptidz-Storage:Backups";
id = "phoenix_b2_backups";
}
{
source = "StorageBox:Photos";
dest = "B2-Phoenix-Cryptidz-Storage:Photos";
id = "phoenix_b2_photos";
}
{
source = "StorageBox:Music";
dest = "B2-Phoenix-Cryptidz-Storage:Music";
id = "phoenix_b2_music";
}
];
};

View file

@ -1,25 +1,14 @@
[StorageBox-Remote]
type = sftp
type = webdav
vendor = nextcloud
host = u323231.your-storagebox.de
url = https://u323231.your-storagebox.de
user = u323231
pass = STORAGEBOX_PASSWORD
port = 23
shell_type = unix
md5sum_command = md5 -r
sha1sum_command = sha1 -r
#type = smb
#type = webdav
#vendor = nextcloud
#host = u323231.your-storagebox.de
#url = https://u323231.your-storagebox.de
#user = u323231
#pass = STORAGEBOX_PASSWORD
[StorageBox]
type = alias
remote = StorageBox-Remote:
#backup
[B2-Chaos-Backups-Source]
type = b2

View file

@ -141,6 +141,7 @@ in {
{
source = "/home/misskey/misskey-files";
dest = "Storage-Media-Crypt:";
id = "misskey_media";
timerConfig = {
OnStartupSec = "60";
OnCalendar = "4h";

View file

@ -7,8 +7,6 @@
with lib; let
cfg = config.services.rclone-sync;
makeNameSafe = name: builtins.replaceStrings ["/" ":"] ["-" "-"] name;
daemonService = sync_config: {
serviceConfig = lib.mkMerge [
{
@ -47,6 +45,8 @@ in {
options = {
source = mkOption {type = types.str;};
dest = mkOption {type = types.str;};
id = mkOption {type = types.str;};
autoRestart = mkOption {
type = types.bool;
default = true;
@ -72,23 +72,33 @@ in {
config = mkMerge [
(mkIf (cfg.enable && cfg.sync_jobs != []) {
envionment.systemPackages = let
allServices = lib.concatStringsSep " " (map (job: "rclone-sync-${makeNameSafe job.source}-${makeNameSafe job.dest}"));
in [
(pkgs.writeShellScriptBin "rclone-sync-all" ''
systemctl stop ${allServices}
systemctl start --wait ${allServices}
'')
];
environment.systemPackages =
[
(pkgs.writeShellScriptBin "rclone-sync-all" (lib.concatStringsSep "\n" (map (
job: ''
${pkgs.rclone}/bin/rclone sync ${job.source} ${job.dest} -P
''
)
cfg.sync_jobs)))
]
++ (
map (
job:
pkgs.writeShellScriptBin "rclone-manual-sync-${job.id}" ''
exec ${pkgs.rclone}/bin/rclone sync ${job.source} ${job.dest} -P
''
)
cfg.sync_jobs
);
systemd.services = listToAttrs (map (job: {
name = "rclone-sync-${makeNameSafe job.source}-${makeNameSafe job.dest}";
name = "rclone-sync-${job.id}";
value = daemonService job;
})
cfg.sync_jobs);
systemd.timers = listToAttrs (map (job: let
name = "rclone-sync-${makeNameSafe job.source}-${makeNameSafe job.dest}";
name = "rclone-sync-${job.id}";
in {
inherit name;
value = {