1{
2 config,
3 pkgs,
4 ...
5}: let
6 localRepo = "/external1/backups/${config.networking.hostName}";
7 mirrorRepo = "/external1/mirrorBackups";
8in {
9 services.restic.backups = {
10 pictures =
11 config.mySnippets.restic
12 // {
13 paths = ["/data/DCIM" "/data/Pictures"];
14 repository = "${localRepo}/pictures";
15 };
16 };
17
18 systemd.services.rclone-mirror = {
19 description = "Sync backups from cloud to local mirror";
20 path = with pkgs; [rclone];
21 serviceConfig = {
22 Type = "oneshot";
23 };
24 script = ''
25 set -e
26 rclone --config ${config.age.secrets.rclone.path} sync "a_gdrive:/backups" "${mirrorRepo}"
27 '';
28 };
29
30 systemd.timers.rclone-mirror = {
31 description = "Run rclone mirror sync daily at 3am";
32 wantedBy = ["timers.target"];
33 timerConfig = {
34 OnCalendar = "*-*-* 03:00:00";
35 Persistent = true;
36 RandomizedDelaySec = "10m";
37 };
38 };
39}