WIP: leonard: add backup.nix, mysqlBackup
This commit is contained in:
43
hosts/leonard/backup.nix
Normal file
43
hosts/leonard/backup.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
services.restic.backups = let
|
||||
localJob = name: paths: {
|
||||
inherit paths;
|
||||
repository = "/mnt/feal-syn1/backup/leonard/${name}"; # TODO - Mount first
|
||||
passwordFile = config.sops.secrets."restic/${name}".path;
|
||||
initialize = true;
|
||||
pruneOpts = [
|
||||
"--keep-daily 3"
|
||||
"--keep-weekly 4"
|
||||
"--keep-monthly 3"
|
||||
];
|
||||
};
|
||||
cloudJob = name: paths: {
|
||||
inherit paths;
|
||||
# "rsyncnet" connection details specified in /root/.ssh/config
|
||||
extraOptions = [ "rclone.program=\"ssh rsyncnet\"" ];
|
||||
# repository = "rclone::/${name}";
|
||||
repository = "rclone:";
|
||||
passwordFile = config.sops.secrets."restic/${name}".path;
|
||||
initialize = true;
|
||||
pruneOpts = [
|
||||
# rsync.net keeps daily snapshots
|
||||
"--keep-weekly 4"
|
||||
"--keep-monthly 36"
|
||||
];
|
||||
};
|
||||
in {
|
||||
# TODO - local NAS backups
|
||||
mysql-remote = (cloudJob "postgres" [ "/var/backup/mysql" ]) // {
|
||||
timerConfig.OnCalendar = "01:30"; # 1h after mysqlBackup
|
||||
};
|
||||
# WIP
|
||||
# postgres-remote = (cloudJob "postgres" [ "/tank/backup/postgresql" ]) // {
|
||||
# timerConfig.OnCalendar = "05:15"; # 2h after postgresqlBackup
|
||||
# };
|
||||
|
||||
};
|
||||
|
||||
sops.secrets."restic/mysql" = { };
|
||||
sops.secrets."restic/postgres" = { };
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
../../common/auto-upgrade.nix
|
||||
./hardware-configuration.nix
|
||||
|
||||
./backup.nix
|
||||
./services/mysql.nix
|
||||
./services/nginx.nix
|
||||
./services/postgresql.nix
|
||||
|
||||
@@ -6,5 +6,8 @@
|
||||
package = pkgs.mariadb;
|
||||
};
|
||||
|
||||
# TODO: services.mysqlBackup
|
||||
services.mysqlBackup = {
|
||||
enable = true;
|
||||
calendar = "00:30:00";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
};
|
||||
}
|
||||
];
|
||||
services.mysqlBackup.databases = [
|
||||
"www_kinealbrigtsen_no"
|
||||
];
|
||||
|
||||
services.phpfpm.pools.www-kinealbrigtsen-no = {
|
||||
user = "www-kinealbrigtsen-no";
|
||||
|
||||
Reference in New Issue
Block a user