dotfiles.nix/home/services/tarsnap.nix

44 lines
1.2 KiB
Nix
Raw Normal View History

2022-10-10 21:54:15 +00:00
{ config, pkgs, ... }: {
# 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"
/opt/homebrew/bin/tarsnap -c \
--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;
}
];
Program = "${tarsnapBackup}/bin/tarsnap-backup-helper";
2022-10-10 21:54:15 +00:00
};
2023-08-23 00:50:29 +00:00
};
2022-10-10 21:54:15 +00:00
# }}}
}