2023-10-26 02:37:42 +00:00
|
|
|
{ config, pkgs, lib, ... }: {
|
2023-11-03 04:12:17 +00:00
|
|
|
# set configuration in ~ so tarsnap cli works interactively
|
|
|
|
home.file.".tarsnaprc".text = ''
|
|
|
|
cachedir ${config.xdg.cacheHome}
|
|
|
|
keyfile ${config.xdg.configHome}/tarsnap/read-write-delete.key
|
|
|
|
nodump
|
|
|
|
print-stats
|
|
|
|
checkpoint-bytes 1G
|
|
|
|
humanize-numbers
|
|
|
|
'';
|
2022-10-10 21:54:15 +00:00
|
|
|
# tarsnap periodic backup configuration
|
2023-08-23 00:50:29 +00:00
|
|
|
launchd.agents.tarsnap = let
|
|
|
|
logPath = "${config.xdg.stateHome}/tarsnap";
|
|
|
|
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
|
|
|
|
date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
echo
|
|
|
|
echo "Running tarsnap backup for $date"
|
2023-10-26 02:37:42 +00:00
|
|
|
${lib.getExe pkgs.tarsnap} -c \
|
2023-08-23 00:50:29 +00:00
|
|
|
--configfile ${config.home.homeDirectory}/.tarsnaprc \
|
|
|
|
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
|
|
|
|
-f $(uname -n)-$date \
|
|
|
|
${config.home.homeDirectory}/{dotfiles.nix,Desktop,Development,Documents,Downloads}
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
enable = true;
|
|
|
|
config = {
|
|
|
|
Label = "com.tarsnap.tarsnap";
|
|
|
|
StandardErrorPath = "${logPath}/error.log";
|
|
|
|
StandardOutPath = "${logPath}/out.log";
|
2023-11-03 04:12:17 +00:00
|
|
|
StartCalendarInterval = [{
|
|
|
|
# every sunday
|
|
|
|
Weekday = 0;
|
|
|
|
# at midnight
|
|
|
|
Hour = 0;
|
|
|
|
Minute = 0;
|
|
|
|
}];
|
2023-10-26 02:37:42 +00:00
|
|
|
Program = lib.getExe tarsnapBackup;
|
2022-10-10 21:54:15 +00:00
|
|
|
};
|
2023-08-23 00:50:29 +00:00
|
|
|
};
|
2022-10-10 21:54:15 +00:00
|
|
|
}
|