Add borgmatic for automatic backups
This commit is contained in:
63
home/borgmatic.nix
Normal file
63
home/borgmatic.nix
Normal 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" ];
|
||||
};
|
||||
}
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user