dotfiles.nix/home/services/tarsnap.nix

46 lines
1.2 KiB
Nix

{ config, pkgs, ... }: {
# tarsnap periodic backup configuration
# {{{
launchd.agents.tarsnap =
let
logPath = "/var/log/tarsnap";
tarsnapBackup = pkgs.writeShellScriptBin "tarsnap-backup-helper" ''
/opt/homebrew/bin/tarsnap -c \
--configfile ${config.home.homeDirectory}/.tarsnaprc \
--keyfile ${config.xdg.configHome}/tarsnap/write-only.key \
-f $(uname -n)-$(date -u +%Y-%m-%dT%H:%M:%SZ) \
${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";
};
};
# }}}
}