rclone sync redo
This commit is contained in:
parent
d0583ddb89
commit
7de328e48f
|
@ -15,27 +15,33 @@
|
||||||
{
|
{
|
||||||
source = "StorageBox:Backups";
|
source = "StorageBox:Backups";
|
||||||
dest = "B2-Chaos-Backups:";
|
dest = "B2-Chaos-Backups:";
|
||||||
|
id = "chaos_b2_backups";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
source = "StorageBox:Photos";
|
source = "StorageBox:Photos";
|
||||||
dest = "B2-Chaos-Photos:";
|
dest = "B2-Chaos-Photos:";
|
||||||
|
id = "chaos_b2_photos";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
source = "StorageBox:Music";
|
source = "StorageBox:Music";
|
||||||
dest = "B2-Chaos-Music:";
|
dest = "B2-Chaos-Music:";
|
||||||
|
id = "chaos_b2_music";
|
||||||
}
|
}
|
||||||
# Pheonix System's B2
|
# Pheonix System's B2
|
||||||
{
|
{
|
||||||
source = "StorageBox:Backups";
|
source = "StorageBox:Backups";
|
||||||
dest = "B2-Phoenix-Cryptidz-Storage:Backups";
|
dest = "B2-Phoenix-Cryptidz-Storage:Backups";
|
||||||
|
id = "phoenix_b2_backups";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
source = "StorageBox:Photos";
|
source = "StorageBox:Photos";
|
||||||
dest = "B2-Phoenix-Cryptidz-Storage:Photos";
|
dest = "B2-Phoenix-Cryptidz-Storage:Photos";
|
||||||
|
id = "phoenix_b2_photos";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
source = "StorageBox:Music";
|
source = "StorageBox:Music";
|
||||||
dest = "B2-Phoenix-Cryptidz-Storage:Music";
|
dest = "B2-Phoenix-Cryptidz-Storage:Music";
|
||||||
|
id = "phoenix_b2_music";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,25 +1,14 @@
|
||||||
[StorageBox-Remote]
|
[StorageBox-Remote]
|
||||||
type = sftp
|
type = webdav
|
||||||
|
vendor = nextcloud
|
||||||
host = u323231.your-storagebox.de
|
host = u323231.your-storagebox.de
|
||||||
|
url = https://u323231.your-storagebox.de
|
||||||
user = u323231
|
user = u323231
|
||||||
pass = STORAGEBOX_PASSWORD
|
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]
|
[StorageBox]
|
||||||
type = alias
|
type = alias
|
||||||
remote = StorageBox-Remote:
|
remote = StorageBox-Remote:
|
||||||
#backup
|
|
||||||
|
|
||||||
[B2-Chaos-Backups-Source]
|
[B2-Chaos-Backups-Source]
|
||||||
type = b2
|
type = b2
|
||||||
|
|
|
@ -141,6 +141,7 @@ in {
|
||||||
{
|
{
|
||||||
source = "/home/misskey/misskey-files";
|
source = "/home/misskey/misskey-files";
|
||||||
dest = "Storage-Media-Crypt:";
|
dest = "Storage-Media-Crypt:";
|
||||||
|
id = "misskey_media";
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnStartupSec = "60";
|
OnStartupSec = "60";
|
||||||
OnCalendar = "4h";
|
OnCalendar = "4h";
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.rclone-sync;
|
cfg = config.services.rclone-sync;
|
||||||
|
|
||||||
makeNameSafe = name: builtins.replaceStrings ["/" ":"] ["-" "-"] name;
|
|
||||||
|
|
||||||
daemonService = sync_config: {
|
daemonService = sync_config: {
|
||||||
serviceConfig = lib.mkMerge [
|
serviceConfig = lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
@ -47,6 +45,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
source = mkOption {type = types.str;};
|
source = mkOption {type = types.str;};
|
||||||
dest = mkOption {type = types.str;};
|
dest = mkOption {type = types.str;};
|
||||||
|
id = mkOption {type = types.str;};
|
||||||
|
|
||||||
autoRestart = mkOption {
|
autoRestart = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -72,23 +72,33 @@ in {
|
||||||
|
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(mkIf (cfg.enable && cfg.sync_jobs != []) {
|
(mkIf (cfg.enable && cfg.sync_jobs != []) {
|
||||||
envionment.systemPackages = let
|
environment.systemPackages =
|
||||||
allServices = lib.concatStringsSep " " (map (job: "rclone-sync-${makeNameSafe job.source}-${makeNameSafe job.dest}"));
|
[
|
||||||
in [
|
(pkgs.writeShellScriptBin "rclone-sync-all" (lib.concatStringsSep "\n" (map (
|
||||||
(pkgs.writeShellScriptBin "rclone-sync-all" ''
|
job: ''
|
||||||
systemctl stop ${allServices}
|
${pkgs.rclone}/bin/rclone sync ${job.source} ${job.dest} -P
|
||||||
systemctl start --wait ${allServices}
|
''
|
||||||
'')
|
)
|
||||||
];
|
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: {
|
systemd.services = listToAttrs (map (job: {
|
||||||
name = "rclone-sync-${makeNameSafe job.source}-${makeNameSafe job.dest}";
|
name = "rclone-sync-${job.id}";
|
||||||
value = daemonService job;
|
value = daemonService job;
|
||||||
})
|
})
|
||||||
cfg.sync_jobs);
|
cfg.sync_jobs);
|
||||||
|
|
||||||
systemd.timers = listToAttrs (map (job: let
|
systemd.timers = listToAttrs (map (job: let
|
||||||
name = "rclone-sync-${makeNameSafe job.source}-${makeNameSafe job.dest}";
|
name = "rclone-sync-${job.id}";
|
||||||
in {
|
in {
|
||||||
inherit name;
|
inherit name;
|
||||||
value = {
|
value = {
|
||||||
|
|
Loading…
Reference in a new issue