diff --git a/role/backup/README.adoc b/role/backup/README.adoc deleted file mode 100644 index 20cbe79..0000000 --- a/role/backup/README.adoc +++ /dev/null @@ -1,3 +0,0 @@ -== Backup Role - -Creates backup to an external mount with borg backup according to a specified schedule. diff --git a/role/backup/default.nix b/role/backup/default.nix deleted file mode 100644 index 5348c9a..0000000 --- a/role/backup/default.nix +++ /dev/null @@ -1,64 +0,0 @@ -# Regular backup role to a separate device -{ systemdMount, # Systemd mount name -borgArchiveFolder, # Absolute borg root folder -keepWithin ? "14d", keepWeekly ? "4", keepMonthly ? "6", keepYearly ? "-1" -, schedule ? "13:37", # Systemd Schedule of backup timer -}: - -let pkgs = import { }; -in { - - systemd = { - services.backup = { - description = - "Backup of all user data and system configuration with BorgBackup"; - serviceConfig.Type = "oneshot"; - path = with pkgs; [ bash borgbackup ]; - script = '' - #!/usr/bin/env bash - set -euo pipefail - IFS=$'\n\t' - - systemctl start ${systemdMount} - - export BORG_REPO=${borgArchiveFolder} \ - BORG_BASE_DIR=${borgArchiveFolder}/borg-base-dir - - echo "Backup started at `date`" - borg create --exclude /var/backup \ - --exclude /var/tmp \ - --exclude /var/cache \ - $BORG_REPO::{hostname}-{now} \ - /etc \ - /home \ - /root \ - /var - - sync - echo "Backup finished at `date`" - - echo "Backup prune started at `date`" - borg prune --prefix '{hostname}-' \ - --keep-within ${keepWithin} \ - --keep-weekly ${keepWeekly} \ - --keep-monthly ${keepMonthly} \ - --keep-yearly ${keepYearly} - sync - echo "Backup prune finished at `date`" - - systemctl stop ${systemdMount} - ''; - }; - - timers.backup = { - description = "Backup Schedule"; - - timerConfig = { - OnCalendar = schedule; - Persistent = "true"; - }; - - wantedBy = [ "timers.target" ]; - }; - }; -}