enhancement/15 #16
1 changed files with 4 additions and 78 deletions
|
|
@ -1,87 +1,13 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
feature = "borgbackup-srv";
|
feature = "borgbackup-srv";
|
||||||
|
|
||||||
secret = "borgbackup";
|
|
||||||
notify =
|
|
||||||
{
|
|
||||||
tag,
|
|
||||||
msg,
|
|
||||||
location,
|
|
||||||
}:
|
|
||||||
''
|
|
||||||
${pkgs.curl}/bin/curl -H "X-Tags: ${tag},BorgBackup,Server,${location}" -d "${msg}" ${config.services.ntfy-sh.settings.base-url}/backups
|
|
||||||
'';
|
|
||||||
notifySuccess =
|
|
||||||
location:
|
|
||||||
notify {
|
|
||||||
tag = "tada";
|
|
||||||
msg = "Backup succeeded";
|
|
||||||
inherit location;
|
|
||||||
};
|
|
||||||
notifyFailure =
|
|
||||||
location:
|
|
||||||
notify {
|
|
||||||
tag = "rotating_light";
|
|
||||||
msg = "Backup failed, check logs";
|
|
||||||
inherit location;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf config.${feature}.enable {
|
config = lib.mkIf config.${feature}.enable {
|
||||||
services.borgbackup.jobs =
|
|
||||||
let
|
|
||||||
srv = location: {
|
|
||||||
paths = [
|
|
||||||
"/srv"
|
|
||||||
"/home/srv/.config/syncthing"
|
|
||||||
"/home/srv/Sync"
|
|
||||||
];
|
|
||||||
|
|
||||||
compression = "auto,zstd";
|
|
||||||
|
|
||||||
startAt = "*-*-* 04:00:00 Australia/Melbourne";
|
|
||||||
|
|
||||||
prune.keep = {
|
|
||||||
daily = 7;
|
|
||||||
weekly = 4;
|
|
||||||
monthly = 6;
|
|
||||||
};
|
|
||||||
|
|
||||||
postHook = ''
|
|
||||||
if [ $exitStatus -eq 0 ]; then
|
|
||||||
${notifySuccess location}
|
|
||||||
else
|
|
||||||
${notifyFailure location}
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
onsite = srv "onsite" // {
|
|
||||||
repo = "/backup/repo";
|
|
||||||
|
|
||||||
encryption.mode = "repokey-blake2";
|
|
||||||
encryption.passCommand = "cat ${config.age.secrets.borgbackup-server-onsite.path}";
|
|
||||||
};
|
|
||||||
|
|
||||||
offsite = srv "offsite" // {
|
|
||||||
repo = "vuc5c3xq@vuc5c3xq.repo.borgbase.com:repo";
|
|
||||||
|
|
||||||
encryption.mode = "repokey-blake2";
|
|
||||||
encryption.passCommand = "cat ${config.age.secrets.borgbackup-server-offsite.path}";
|
|
||||||
|
|
||||||
environment.BORG_RSH = "ssh -i /home/srv/.ssh/id_ed25519";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# onsite drive
|
# onsite drive
|
||||||
services.udisks2.enable = true;
|
services.udisks2.enable = true;
|
||||||
|
|
||||||
|
|
@ -92,11 +18,11 @@ in
|
||||||
|
|
||||||
# secrets
|
# secrets
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
"${secret}-server-onsite" = {
|
"borgbackup-server-onsite" = {
|
||||||
file = ../../../secrets/${secret}-server-onsite.age;
|
file = ../../../secrets/borgbackup-server-onsite.age;
|
||||||
};
|
};
|
||||||
"${secret}-server-offsite" = {
|
"borgbackup-server-offsite" = {
|
||||||
file = ../../../secrets/${secret}-server-offsite.age;
|
file = ../../../secrets/borgbackup-server-offsite.age;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue