Btrbk: Difference between revisions
Retention policy |
No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 33: | Line 33: | ||
target = "ssh://myhost/mnt/mybackups"; | target = "ssh://myhost/mnt/mybackups"; | ||
subvolume = "nixos"; | subvolume = "nixos"; | ||
# "nixos" could instead be an attribute set with other volumes to | |||
# back up and to give subvolume specific configuration. | |||
# See man btrbk.conf for possible options. | |||
/* | |||
subvolume = { | |||
home = { snapshot_create = "always"; }; | |||
nixos = {}; | |||
}; | |||
*/ | |||
}; | }; | ||
}; | }; | ||
Line 69: | Line 78: | ||
environment.systemPackages = [ pkgs.lz4 ]; | environment.systemPackages = [ pkgs.lz4 ]; | ||
</nowiki>}} | |||
=== Local <code>/home</code> Snapshots === | |||
{{Warning|This is not a backup solution alone. If the entire disk fails, local snapshots will be lost along with it.}} | |||
If <code>/home</code> is its own subvolume and important files are backed up separately or combined with the above section, this configuration takes snapshots hourly, retains them for at least a week, and keeps weekly snapshots for two weeks under <code>/snapshots</code>. | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | |||
services.btrbk = { | |||
instances."home" = { | |||
onCalendar = "hourly"; | |||
settings = { | |||
snapshot_preserve_min = "1w"; | |||
snapshot_preserve = "2w"; | |||
volume = { | |||
"/" = { | |||
snapshot_dir = "/snapshots"; | |||
subvolume = "home"; | |||
}; | |||
}; | |||
}; | |||
}; | |||
}; | |||
# Btrbk does not create snapshot directories automatically, so create one here. | |||
systemd.tmpfiles.rules = [ | |||
"d /snapshots 0755 root root" | |||
]; | |||
</nowiki>}} | </nowiki>}} | ||