Add borgmatic for automatic backups

This commit is contained in:
Weckyy702
2026-02-12 23:39:31 +01:00
parent 9ea1f7801f
commit 63afa59e34
2 changed files with 64 additions and 0 deletions

63
home/borgmatic.nix Normal file
View File

@@ -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" ];
};
}

View File

@@ -9,6 +9,7 @@ top @ { config
inputs.catppuccin.homeModules.catppuccin inputs.catppuccin.homeModules.catppuccin
inputs.spicetify-nix.homeManagerModules.default inputs.spicetify-nix.homeManagerModules.default
./nixvim ./nixvim
./borgmatic.nix
]; ];
#NOTE: MUST be kept up to date with nixpkgs! #NOTE: MUST be kept up to date with nixpkgs!