]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/system/backup-2.nix
Add monitoring for backup-2
[perso/Immae/Config/Nix.git] / modules / private / system / backup-2.nix
1 { privateFiles }:
2 { config, pkgs, myconfig, resources, ... }:
3 {
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 _module.args.privateFiles = privateFiles;
6 _module.args.hostFQDN = "backup-2.v.immae.eu";
7 imports = builtins.attrValues (import ../..);
8
9 deployment = {
10 targetEnv = "hetznerCloud";
11 hetznerCloud = {
12 authToken = myconfig.env.hetznerCloud.authToken;
13 datacenter = "hel1-dc2";
14 location ="hel1";
15 serverType = "cx11";
16 };
17 };
18
19 fileSystems = {
20 "/backup2" = {
21 fsType = "ext4";
22 device = "UUID=b9425333-f567-435d-94d8-b26c22d93426";
23 };
24 };
25
26 networking = {
27 firewall.enable = true;
28 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
29 (n: ips: { address = ips.ip4; prefixLength = 32; })
30 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.backup-2.ips);
31 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
32 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
33 myconfig.env.servers.backup-2.ips);
34
35 defaultMailServer = {
36 directDelivery = true;
37 hostName = "eldiron.immae.eu:25";
38 useTLS = true;
39 useSTARTTLS = true;
40 root = "postmaster@immae.eu";
41 };
42 };
43
44 services.rsyncBackup = {
45 mountpoint = "/backup2";
46 mailto = myconfig.env.rsync_backup.mailto;
47 profiles = myconfig.env.rsync_backup.profiles;
48 ssh_key_public = myconfig.env.rsync_backup.ssh_key.public;
49 ssh_key_private = myconfig.env.rsync_backup.ssh_key.private;
50 };
51
52 myServices.monitoring.enable = true;
53 myServices.databasesReplication = {
54 postgresql = {
55 enable = true;
56 base = "/backup2";
57 hosts = {
58 eldiron = {
59 slot = "backup_2";
60 connection = "postgresql://backup-2:${myconfig.env.ldap.backup-2.password}@eldiron.immae.eu";
61 };
62 };
63 };
64 };
65
66 # This value determines the NixOS release with which your system is
67 # to be compatible, in order to avoid breaking some software such as
68 # database servers. You should change this only after NixOS release
69 # notes say you should.
70 # https://nixos.org/nixos/manual/release-notes.html
71 system.stateVersion = "19.03"; # Did you read the comment?
72 }