From 83253ed9f8f2cdb5eb55f941a8aac9aba1576d83 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 21 Mar 2021 18:23:32 +0100 Subject: [PATCH] heater and nextcloud backup improvments --- configs/pepe/borg.nix | 16 ++++++++++++++++ configs/pepe/syncthing.nix | 6 ++++++ configs/workhorse/borg.nix | 16 ++++++++++++++++ configs/workhorse/nextcloud.nix | 31 +++++++++++++++++++++++++++++++ configs/workhorse/syncthing.nix | 6 ++++++ mqtt/fyrtur.py | 8 ++++---- mqtt/heater.py | 22 +++++++++++----------- system/all/syncthing.nix | 5 +++++ system/all/tinc.nix | 6 +++--- 9 files changed, 98 insertions(+), 18 deletions(-) diff --git a/configs/pepe/borg.nix b/configs/pepe/borg.nix index 5fd86c4..a7b8855 100644 --- a/configs/pepe/borg.nix +++ b/configs/pepe/borg.nix @@ -13,4 +13,20 @@ }; }; + # mirror backup folder to /media + systemd.services.borg-mirror-to-media = { + enable = true; + script = '' + ${pkgs.rsync}/bin/rsync -a \ + /var/lib/borgbackup/ \ + /media/borg-backup-mirror \ + --delete-after + ''; + }; + systemd.timers.borg-mirror-to-media = { + enable = true; + timerConfig.OnCalendar = "daily"; + wantedBy = [ "multi-user.target" ]; + }; + } diff --git a/configs/pepe/syncthing.nix b/configs/pepe/syncthing.nix index f0e451c..c6b79bf 100644 --- a/configs/pepe/syncthing.nix +++ b/configs/pepe/syncthing.nix @@ -56,6 +56,12 @@ # no need to be encrypted # ----------------------- + borg-mirror = { + enable = true; + path = "/media/syncthing/borg"; + rescanInterval = 36 * 3600; + type = "receiveonly"; + }; books = { enable = true; path = "/media/syncthing/books"; diff --git a/configs/workhorse/borg.nix b/configs/workhorse/borg.nix index 4033520..9de4c76 100644 --- a/configs/workhorse/borg.nix +++ b/configs/workhorse/borg.nix @@ -11,4 +11,20 @@ }; }; + # mirror backup folder to /media + systemd.services.borg-mirror-to-media = { + enable = true; + script = '' + ${pkgs.rsync}/bin/rsync -a \ + /var/lib/borgbackup/ \ + /media/borg-backup-mirror \ + --delete-after + ''; + }; + systemd.timers.borg-mirror-to-media = { + enable = true; + timerConfig.OnCalendar = "daily"; + wantedBy = [ "multi-user.target" ]; + }; + } diff --git a/configs/workhorse/nextcloud.nix b/configs/workhorse/nextcloud.nix index 023db6e..53c9d83 100644 --- a/configs/workhorse/nextcloud.nix +++ b/configs/workhorse/nextcloud.nix @@ -261,4 +261,35 @@ in { }; }; + services.borgbackup.jobs = { + "nextcloud-to-media" = { + repo = "/media/syncthing/borg/nextcloud"; + # make sure syncthing is capable of reading the files + postHook = '' + chown syncthing:syncthing -R /media/syncthing/borg + ''; + compression = "lz4"; + paths = [ + "/home/nextcloud/data/tina/files/Documents" + "/home/nextcloud/data/tina/files/Pictures" + "/home/nextcloud/data/tina/files/Joplin" + "/home/nextcloud/data/tina/files/SofortUpload" + "/home/nextcloud/data/palo/files/Joplin" + "/home/nextcloud/data/palo/files/InstantUpload" + ]; + doInit = true; + encryption = { + mode = "repokey-blake2"; + passCommand = "cat ${toString }"; + }; + startAt = "0/3:00:00"; + prune.keep = { + within = "2d"; # Keep all backups in the last 10 days. + daily = 10; # Keep 10 additional end of day archives + weekly = 8; # Keep 8 additional end of week archives. + month = 8; # Keep 8 additional end of month archives. + }; + }; + }; + } diff --git a/configs/workhorse/syncthing.nix b/configs/workhorse/syncthing.nix index 69378a1..43492ef 100644 --- a/configs/workhorse/syncthing.nix +++ b/configs/workhorse/syncthing.nix @@ -52,6 +52,12 @@ # on media hard drive (not encrypted) # ----------------------------------- + borg-mirror = { + enable = true; + path = "/media/syncthing/borg"; + rescanInterval = 36 * 3600; + type = "sendonly"; + }; video-material = { enable = true; path = "/home/syncthing/video-material"; diff --git a/mqtt/fyrtur.py b/mqtt/fyrtur.py index 3eaabe5..8f81de8 100644 --- a/mqtt/fyrtur.py +++ b/mqtt/fyrtur.py @@ -109,7 +109,7 @@ def update_scene(client): watcher.update("office1", Position.DOWN) watcher.update("office2", Position.DOWN) watcher.update("bedroom", Position.DOWN) - elif scene in ["default", "up-bright", "up-dark" "outside"]: + elif scene in ["default", "up-bright", "up-dark", "outside"]: watcher.update("office1", Position.UP) watcher.update("office2", Position.UP) watcher.update("bedroom", Position.UP) @@ -118,9 +118,9 @@ def update_scene(client): watcher.update("office2", Position.HALF) watcher.update("bedroom", Position.HALF) else: - watcher.update("office1", Position.DOWN) - watcher.update("office2", Position.DOWN) - watcher.update("bedroom", Position.DOWN) + watcher.update("office1", Position.UP) + watcher.update("office2", Position.UP) + watcher.update("bedroom", Position.UP) watcher.publish(client) diff --git a/mqtt/heater.py b/mqtt/heater.py index a830e22..6dad885 100644 --- a/mqtt/heater.py +++ b/mqtt/heater.py @@ -8,8 +8,8 @@ from typing import Dict class Heater: def __init__(self, topic): self.not_initialized_yet = True - self.wanted_temperature = 10 - self.actual_temperature = 10 + self.wanted_temperature = 14 + self.actual_temperature = 14 self.topic = topic def needs_publish(self): @@ -124,17 +124,17 @@ def parse_message(msg): def update_scene(client): if scene in ["night", "outside"]: - watcher.update("office1", 10) - watcher.update("office2", 10) - watcher.update("bedroom", 10) + watcher.update("office1", 14) + watcher.update("office2", 14) + watcher.update("bedroom", 14) elif scene in ["default", "up-bright", "up-dark", "half", "down"]: - watcher.update("office1", 26) - watcher.update("office2", 26) - watcher.update("bedroom", 18) + watcher.update("office1", 28) + watcher.update("office2", 28) + watcher.update("bedroom", 20) else: - watcher.update("office1", 10) - watcher.update("office2", 10) - watcher.update("bedroom", 10) + watcher.update("office1", 14) + watcher.update("office2", 14) + watcher.update("bedroom", 14) watcher.publish(client) diff --git a/system/all/syncthing.nix b/system/all/syncthing.nix index 688e094..3b4e22f 100644 --- a/system/all/syncthing.nix +++ b/system/all/syncthing.nix @@ -109,6 +109,11 @@ with lib; { # no need to be stored on encrypted drives # ---------------------------------------- + borg-mirror = { + enable = lib.mkDefault false; + watch = false; + devices = [ "workhorse" "pepe" ]; + }; books = { enable = lib.mkDefault false; id = "wwbvs-5lfbh"; diff --git a/system/all/tinc.nix b/system/all/tinc.nix index 4079662..9b762ed 100644 --- a/system/all/tinc.nix +++ b/system/all/tinc.nix @@ -2,9 +2,9 @@ let retiolum = pkgs.fetchgit { - url = "https://github.com/krebs/retiolum.git"; - rev = "9dd1b68e9634b5e99650b33974f55d4ce384cab7"; - sha256 = "019qyrxfw0a6jqa3pmhx6ghzdjxdrnf97r6mvsv42rpxc17vvdaz"; + url = "https://github.com/krebs/retiolum"; + rev = "5b067937a10ea43f88f14cc6e0a5485c2ddcc826"; + sha256 = "0kczrr6dr5dmhx2kbanw46w6ig2v3w42rqhjanv87xhwkgw81l08"; }; in {