2023-10-26 02:37:42 +00:00
|
|
|
{ config, pkgs, lib, ... }: {
|
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";
|
|
|
|
StartCalendarInterval = [
|
|
|
|
{
|
|
|
|
# every sunday
|
|
|
|
Weekday = 0;
|
|
|
|
# at midnight
|
|
|
|
Hour = 0;
|
|
|
|
Minute = 0;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# every wednesday
|
|
|
|
Weekday = 3;
|
|
|
|
# at noon
|
|
|
|
Hour = 12;
|
|
|
|
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
|
|
|
}
|