diff --git a/backup.nix b/backup.nix index 0d740ef..dba4cc5 100644 --- a/backup.nix +++ b/backup.nix @@ -27,4 +27,30 @@ let systemctl start forgejo.service # Prune old backups ${pkgs.borgbackup}/bin/borg prune --list $BORG_REPO --prefix 'forgejo-' --show-rc --keep-daily=7 --keep-weekly=4 --keep-monthly=6 - ''; \ No newline at end of file + ''; + in + { + environment.systemPackages = [ pkgs.borgbackup ]; + # Create folders + systemd.tmpfiles.rules = [ + "d /borgbackupcache 700 root root" + ]; + # Backup timer + systemd.services.borg-backup = { + description = "Borg Backup for Forgejo and MySQL"; + serviceConfig = { + ExecStart = "${forgejo-borgbackup}"; + User = "root"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.timers.borg-backup = { + description = "Daily Borg Backup Timer"; + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + }; + }; + } \ No newline at end of file diff --git a/configuration.nix b/configuration.nix index 7eee503..1bed360 100644 --- a/configuration.nix +++ b/configuration.nix @@ -56,13 +56,9 @@ vim wget curl - borgbackup ]; - # Create folders - systemd.tmpfiles.rules = [ - "d /borgbackupcache 700 root root" - ]; + # Enable the OpenSSH daemon. @@ -111,25 +107,6 @@ AuthorizedKeysFile ${config.users.users.forgejo.home}/.ssh/authorized_keys ''; - # Backup timer - systemd.services.borg-backup = { - description = "Borg Backup for Forgejo and MySQL"; - serviceConfig = { - ExecStart = "${forgejo-borgbackup}"; - User = "root"; - }; - wantedBy = [ "multi-user.target" ]; - }; - - systemd.timers.borg-backup = { - description = "Daily Borg Backup Timer"; - wantedBy = [ "timers.target" ]; - timerConfig = { - OnCalendar = "daily"; - Persistent = true; - }; - }; - #enable qemu-guestagent services.qemuGuest.enable = true; # Disable password checking for wheel group users so we can solely rely on ssh keys