From abf56b1de8d8526f37f82bbfdd7bb2840b4f6b09 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Wed, 4 Oct 2023 14:43:57 +0200 Subject: [PATCH] btrbk: local backups --- modules/btrbk/README.md | 2 ++ modules/btrbk/default.nix | 49 +++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/modules/btrbk/README.md b/modules/btrbk/README.md index ff2cae0..2abef6f 100644 --- a/modules/btrbk/README.md +++ b/modules/btrbk/README.md @@ -241,8 +241,10 @@ Another remote backup server periodically pulls snapshots to create remote backu ```shell cat > ~/btrbk.cfg <<'EOF' timestamp_format long +stream_compress lz4 ssh_identity /mnt/backup/rootnas_ed25519 +# Create backups. target_preserve_min no # Daily backups -> @daily cron entry target_preserve 7d 4w 6m diff --git a/modules/btrbk/default.nix b/modules/btrbk/default.nix index 32ac231..66a8fad 100644 --- a/modules/btrbk/default.nix +++ b/modules/btrbk/default.nix @@ -6,11 +6,12 @@ # #=> btrbk-.service # #=> btrbk-.timer # - # If onCalendar is set to null, one can manually execute btrbk with + # If onCalendar is set to `null`, one can manually execute btrbk with # sudo systemctl start btrbk-.service # Print generated systemd unit file # cat "$(systemctl show -P FragmentPath btrbk-.service)" + # #=> ExecStart=/nix/store/53nvbl1c0w14524j7v3fpn9py31yi2hb-btrbk-0.32.6/bin/btrbk -c /etc/btrbk/local-backup.conf run services.btrbk = { extraPackages = [ pkgs.lz4 ]; @@ -19,16 +20,16 @@ # Set of btrbk instances. The instance named btrbk is the default one. instances = { - "local-snapshots" = { + "local-snapshot" = { onCalendar = "hourly"; #onCalendar = "*:0/15"; # Every 15min settings = { timestamp_format = "long"; - stream_compress = "lz4"; + #stream_compress = "lz4"; snapshot_preserve_min = "2d"; - snapshot_preserve = "24h 7d 4w 6m"; + snapshot_preserve = "24h 7d 4w 6m"; volume."/mnt/data/data" = { snapshot_dir = "/mnt/data/snap"; @@ -36,6 +37,46 @@ "arch.p1st.de" = {}; "blogger.privacy1st.de" = {}; "changedetection.p1st.de" = {}; + # MediaKollektiv: 796 GiB + "cloud.media-kollektiv.eu" = {}; + "cloud.privacy1st.de" = {}; + "git.privacy1st.de" = {}; + #"mastodon-toot-follower.privacy1st.de" = {}; + "money.p1st.de" = {}; + "music.privacy1st.de" = {}; + #"paste.p1st.de" = {}; + "proxy" = {}; + "recipe.privacy1st.de" = {}; + "traggo.privacy1st.de" = {}; + }; + }; + }; + }; + + "local-backup" = { + # Run daily, 5 minutes after `local-snapshot` 0'o'clock timer. + onCalendar = "00:05"; + + settings = { + timestamp_format = "long"; + #stream_compress = "lz4"; + + # Create backups. + target_preserve_min = "no"; + target_preserve = "7d 4w 6m"; + + # Don't create or delete snapshots. + snapshot_preserve_min = "all"; + snapshot_create = "no"; + + volume."/mnt/data/data" = { + snapshot_dir = "/mnt/data/snap"; + target = "/mnt/backup/snap"; + subvolume = { + "arch.p1st.de" = {}; + "blogger.privacy1st.de" = {}; + "changedetection.p1st.de" = {}; + # MediaKollektiv: 796 GiB "cloud.media-kollektiv.eu" = {}; "cloud.privacy1st.de" = {}; "git.privacy1st.de" = {};