Btrbk: Difference between revisions

Onny (talk | contribs)
Remove unstable notice
Onny (talk | contribs)
Retention policy
Line 17: Line 17:
== Configuration ==
== Configuration ==


=== Basic example ===
Following example configuration will create a weekly incremental backup of a local Btrfs subvolume called <code>nixos</code> and sends it compressed to the remote host <code>myhost</code>. The mount point <code>/btr_pool</code>, as referenced above, contains the subvolume.
Following example configuration will create a weekly incremental backup of a local Btrfs subvolume called <code>nixos</code> and sends it compressed to the remote host <code>myhost</code>. The mount point <code>/btr_pool</code>, as referenced above, contains the subvolume.


Line 69: Line 70:
environment.systemPackages = [ pkgs.lz4 ];
environment.systemPackages = [ pkgs.lz4 ];
</nowiki>}}
</nowiki>}}
=== Retention policy ===
The following example takes daily snapshot but won't store them forever with the given retention policy:
* '''7d''': For the most recent week, you will have a '''daily snapshot''' stored from each day.
* '''4w''': After a week, you'll only keep one snapshot per week for the next 4 weeks (so older daily snapshots get removed).
* '''12m''': After a month, the policy will keep only '''monthly snapshots''' for the next 12 months.
The option <code>snapshot_preserve_min</code>ensures that all daily snapshots from the last 7 days are preserved, regardless of the other retention rules. It's a safety net to guarantee that no daily snapshot from the past week is deleted prematurely.<syntaxhighlight lang="nix">
services.btrbk.instances."remote_myhost" = {
  onCalendar = "daily";
  settings = {
      snapshot_preserve = "7d 4w 12m";
      snapshot_preserve_min = "7d";
      target_preserve = "7d 4w 12m";
  };
};
</syntaxhighlight>This retention policy will ensure you have a balance between recent, frequent backups (daily) and older, more spaced-out backups (weekly/monthly) while preserving space.


== Manual usage ==
== Manual usage ==