mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 23:29:08 +01:00
restic: Add restic-backup-all and restic-restore-all scripts
This commit is contained in:
parent
a322ebb623
commit
fe94d7f146
2 changed files with 46 additions and 20 deletions
|
|
@ -1,4 +1,9 @@
|
||||||
{ config, lib, ... }:
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
backups =
|
backups =
|
||||||
config.custom.services.restic.backups |> lib.attrValues |> lib.filter (backup: backup.enable);
|
config.custom.services.restic.backups |> lib.attrValues |> lib.filter (backup: backup.enable);
|
||||||
|
|
@ -92,5 +97,16 @@ in
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|> lib.listToAttrs;
|
|> lib.listToAttrs;
|
||||||
|
|
||||||
|
environment.systemPackages =
|
||||||
|
let
|
||||||
|
backupAllScript = pkgs.writeShellApplication {
|
||||||
|
name = "restic-backup-all";
|
||||||
|
text = "systemctl start restic-backups-{${
|
||||||
|
backups |> lib.map (backup: backup.name) |> lib.concatStringsSep ","
|
||||||
|
}}";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
[ backupAllScript ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
|
let
|
||||||
|
restoreScripts =
|
||||||
backupsWithRestoreCommand
|
backupsWithRestoreCommand
|
||||||
|> lib.map (
|
|> lib.map (
|
||||||
backup:
|
backup:
|
||||||
|
|
@ -52,5 +54,13 @@ in
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
restoreAllScript = pkgs.writeShellApplication {
|
||||||
|
name = "restic-restore-all";
|
||||||
|
text =
|
||||||
|
backupsWithRestoreCommand |> lib.map (backup: "restic-restore-${backup.name}") |> lib.concatLines;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
restoreScripts ++ [ restoreAllScript ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue