2022-10-10 21:54:15 +00:00
|
|
|
{ config, pkgs, ... }: {
|
|
|
|
# tarsnap periodic backup configuration
|
|
|
|
# {{{
|
|
|
|
launchd.agents.tarsnap =
|
|
|
|
let
|
2022-11-09 00:11:02 +00:00
|
|
|
logPath = "${config.xdg.stateHome}/tarsnap";
|
2022-10-10 21:54:15 +00:00
|
|
|
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
|
2023-01-04 17:05:00 +00:00
|
|
|
date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
echo
|
|
|
|
echo "Running tarsnap backup for $date"
|
2022-10-16 23:43:04 +00:00
|
|
|
/opt/homebrew/bin/tarsnap -c \
|
2022-10-10 21:54:15 +00:00
|
|
|
--configfile ${config.home.homeDirectory}/.tarsnaprc \
|
2022-10-16 23:43:04 +00:00
|
|
|
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
|
2023-01-04 17:05:00 +00:00
|
|
|
-f $(uname -n)-$date \
|
2022-10-10 21:54:15 +00:00
|
|
|
${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;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# }}}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|