diff --git a/home/borgmatic.nix b/home/borgmatic.nix new file mode 100644 index 0000000..4ec565a --- /dev/null +++ b/home/borgmatic.nix @@ -0,0 +1,63 @@ +{ hostname +, username +, pkgs +, ... +}: { + home.packages = with pkgs; [ + libnotify + ]; + + programs.borgmatic = { + enable = true; + package = pkgs.borgmatic; + + backups.default = { + location = { + repositories = [ + { + label = "duke"; + path = "ssh://borg@duke.veltnet:2222/home/borg/backups/${hostname}-${username}"; + } + ]; + excludeHomeManagerSymlinks = true; + patterns = [ + #TODO: home.homeDirectory might be usable here + "R /home/${username}/Documents" + "R /home/${username}/.ssh" + "- /home/${username}/Documents/SteamLibrary" + "- /home/${username}/Documents/PrismLauncher instances" + "- /home/${username}/Documents/.Trash-1000" + "- /home/${username}/Documents/VMs/Data" + "- **/node_modules" + "- **/.git" + "- **/.cache" + "- **/*build" + "- **/target" + "- **/.venv" + "- **/venv" + "- **/.gradle" + "- **/out" + "- **/dist" + "- **/.pio" + ]; + }; + retention.keepWeekly = 2; + storage.extraConfig.ssh_command = "ssh -i /home/${username}/.ssh/id_ed25519_borg"; + #FIXME: consistency checks!!! + }; + }; + + systemd.user.services.borgmatic = { + Unit.Description = "Create a backup using borgmatic"; + Service.ExecStart = "${pkgs.borgmatic}/bin/borgmatic create --stats"; + }; + + systemd.user.timers.borgmatic = { + Unit.Description = "Create weekly backups using borgmatic"; + Timer = { + OnCalendar = "Weekly"; + Persistent = true; + }; + Install.WantedBy = [ "timers.target" ]; + }; +} diff --git a/home/home.nix b/home/home.nix index 5964a14..6d0f26f 100644 --- a/home/home.nix +++ b/home/home.nix @@ -9,6 +9,7 @@ top @ { config inputs.catppuccin.homeModules.catppuccin inputs.spicetify-nix.homeManagerModules.default ./nixvim + ./borgmatic.nix ]; #NOTE: MUST be kept up to date with nixpkgs!