Skip to content

Commit

Permalink
Move Radarr logs backup into Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
samhh committed Jan 28, 2023
1 parent ddc211c commit d4bf85a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 15 deletions.
5 changes: 0 additions & 5 deletions hosts/alakazam/scripts/backup.sh

This file was deleted.

Binary file removed hosts/alakazam/scripts/seedbox/radarr.sh
Binary file not shown.
48 changes: 38 additions & 10 deletions hosts/tentacool/backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
{ config, pkgs, ... }:

let
radarrLogs = pkgs.writeShellScript "radarr-logs" ''
endpoint="$(cat ${config.age.secrets.radarr-host.path})/api/v3/movie"
auth="X-Api-Key: $(cat ${config.age.secrets.radarr-api-key.path})"
${pkgs.curl}/bin/curl -s -H "$auth" "$endpoint" | \
${pkgs.jq}/bin/jq -r 'map(.title + " HASFILE:" + (.hasFile | tostring)) | join("\n")' > \
${config.nas.path}/logs/radarr.txt
'';

sonarrLogs = pkgs.writeShellScript "sonarr-logs" ''
endpoint="$(cat ${config.age.secrets.sonarr-host.path})/api/v3/series"
auth="X-Api-Key: $(cat ${config.age.secrets.sonarr-api-key.path})"
Expand Down Expand Up @@ -92,19 +101,38 @@ in
};

systemd = {
services."sonarr-logs" = {
description = "Sonarr logs";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = sonarrLogs;
services = {
"radarr-logs" = {
description = "Radarr logs";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = radarrLogs;
};
};

"sonarr-logs" = {
description = "Sonarr logs";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = sonarrLogs;
};
};
};

timers."sonarr-logs" = {
description = "Run Sonarr logs";
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "daily";
timers = {
"radarr-logs" = {
description = "Run Radarr logs";
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "daily";
};

"sonarr-logs" = {
description = "Run Sonarr logs";
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "daily";
};
};
};
}
2 changes: 2 additions & 0 deletions hosts/tentacool/secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
age.secrets = {
ddns-token.file = ../../secrets/ddns-token.age;
pihole-env.file = ../../secrets/pihole-env.age;
radarr-api-key.file = ../../secrets/radarr-api-key.age;
radarr-host.file = ../../secrets/radarr-host.age;
radicale-htpasswd = {
file = ../../secrets/radicale-htpasswd.age;
owner = "radicale";
Expand Down
7 changes: 7 additions & 0 deletions secrets/radarr-api-key.age
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
age-encryption.org/v1
-> ssh-ed25519 8xjxwA KCo5kTlJfTYq/4XdVLa8dkkis5FivxUFcjCin9+s8yI
Bdl2deRxMoNge/qfXPluktglG356xZIfkzzUu7/bZ4o
-> `-grease
dwMcCu3g8oqx1UA9oCkvjK8cx0m0ZBu/guKv3KIWO4FY7Kxe2/D5erN8YOp0VA
--- w1ryOAHwvozO0T7IUv2aDV/OUqXM6MKne9GQlZJd61Y
�:�7<`Hŭ���6o���$�yh�8�w���}M�Fq�"L*uI��^y:�S:�Ĩ'�ۉx
Expand Down
9 changes: 9 additions & 0 deletions secrets/radarr-host.age
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
age-encryption.org/v1
-> ssh-ed25519 8xjxwA olbBFZjuhGBJhTwrIKvLWBi1DUwi59xSwEVef4aeJw0
IVg18JjmLylVa4WxnHryIZ2WJDodm2DOVKjJ1zd74lE
-> G"TV-grease FN(U L~?)JoX )EJL1N

--- vbwKpzO9nEYbuzdJH7zTW9E6Mn4qRYIuIjh3pYLZPeE
�ʫ<���?V���ȷ�PT
t���2cӍq] ?�@Pb5mU[��y$@��\�q2Fc��(�
hv�L��oW
2 changes: 2 additions & 0 deletions secrets/secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ in
"krabby.age".publicKeys = [ alakazam ];
"migadu.age".publicKeys = [ alakazam tentacool ];
"pihole-env.age".publicKeys = [ tentacool ];
"radarr-api-key.age".publicKeys = [ tentacool ];
"radarr-host.age".publicKeys = [ tentacool ];
"radicale-htpasswd.age".publicKeys = [ tentacool ];
"restic.age".publicKeys = [ alakazam tentacool ];
"sonarr-api-key.age".publicKeys = [ tentacool ];
Expand Down

0 comments on commit d4bf85a

Please sign in to comment.