54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
| # TODO: 
 | |
| # This currently works on a per host basis, and the host file has to define all the locations it wants to back up.
 | |
| # Ideally, this would create a job for each profile instead, so the backup strategy is included in the profile regardless of host
 | |
| { config, lib, pkgs, ... }:
 | |
| with lib;
 | |
| let
 | |
|   cfg = config.mossnet.backup;
 | |
| in
 | |
| {
 | |
|   options = {
 | |
|     mossnet.backup = {
 | |
|       enable = mkEnableOption "Backup module using borg for Anish's computer nursery";
 | |
|       name = lib.mkOption {
 | |
|         type = types.str;
 | |
|         default = { };
 | |
|         example = literalExample ''
 | |
|           mossnet
 | |
|         '';
 | |
|         description = ''
 | |
|           name for the backup operator
 | |
|         '';
 | |
|       };
 | |
|       paths = lib.mkOption {
 | |
|         type = with types; listOf str;
 | |
|         default = { };
 | |
|         example = literalExample ''
 | |
|           [ "/home/anish/usr" ];
 | |
|         '';
 | |
|         description = ''
 | |
|           A list of folders to backup
 | |
|         '';
 | |
|       };
 | |
|     };
 | |
|   };
 | |
| 
 | |
|   config = mkIf cfg.enable {
 | |
|     services.borgbackup.jobs = {
 | |
|       "${cfg.name}" = {
 | |
|         paths = cfg.paths;
 | |
|         doInit = true;
 | |
|         repo = "20779@hk-s020.rsync.net:${cfg.name}";
 | |
|         encryption = {
 | |
|           mode = "repokey-blake2";
 | |
|           passCommand = "cat /run/agenix/borg-password";
 | |
|         };
 | |
|         environment = { BORG_RSH = "ssh -i /run/agenix/borg-key"; };
 | |
|         compression = "auto,lzma";
 | |
|         startAt = "daily";
 | |
|         extraArgs = "--remote-path=borg1";
 | |
|       };
 | |
|     };
 | |
|   };
 | |
| }
 |