2023-09-27 18:56:12 +02:00
|
|
|
{ config, pkgs, ... }:
|
2023-11-15 13:52:21 +01:00
|
|
|
let
|
|
|
|
ssd-subvolumes = {
|
|
|
|
"arch.p1st.de" = {};
|
|
|
|
"blogger.privacy1st.de" = {};
|
|
|
|
"changedetection.p1st.de" = {};
|
|
|
|
"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" = {};
|
|
|
|
};
|
|
|
|
hdd-subvolumes = {
|
|
|
|
"cloud.privacy1st.de" = {};
|
|
|
|
# MediaKollektiv: 796 GiB
|
|
|
|
"cloud.media-kollektiv.eu" = {};
|
|
|
|
};
|
|
|
|
in
|
2023-09-27 18:56:12 +02:00
|
|
|
{
|
|
|
|
# For each instance, a service and timer will be created:
|
|
|
|
# systemctl list-unit-files | grep btrbk
|
|
|
|
# #=> btrbk-<instance-name>.service
|
|
|
|
# #=> btrbk-<instance-name>.timer
|
|
|
|
#
|
2023-10-04 14:43:57 +02:00
|
|
|
# If onCalendar is set to `null`, one can manually execute btrbk with
|
2023-09-27 18:56:12 +02:00
|
|
|
# sudo systemctl start btrbk-<instance-name>.service
|
|
|
|
|
|
|
|
# Print generated systemd unit file
|
|
|
|
# cat "$(systemctl show -P FragmentPath btrbk-<instance-name>.service)"
|
2023-10-04 14:43:57 +02:00
|
|
|
# #=> ExecStart=/nix/store/53nvbl1c0w14524j7v3fpn9py31yi2hb-btrbk-0.32.6/bin/btrbk -c /etc/btrbk/local-backup.conf run
|
2023-09-27 18:56:12 +02:00
|
|
|
|
|
|
|
services.btrbk = {
|
|
|
|
extraPackages = [ pkgs.lz4 ];
|
|
|
|
# Lowest scheduling priority.
|
|
|
|
niceness = 19;
|
|
|
|
# Set of btrbk instances. The instance named btrbk is the default one.
|
|
|
|
instances = {
|
|
|
|
|
2023-10-04 14:43:57 +02:00
|
|
|
"local-snapshot" = {
|
2023-09-27 18:56:12 +02:00
|
|
|
onCalendar = "hourly";
|
|
|
|
#onCalendar = "*:0/15"; # Every 15min
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
timestamp_format = "long";
|
2023-10-04 14:43:57 +02:00
|
|
|
#stream_compress = "lz4";
|
2023-09-27 18:56:12 +02:00
|
|
|
|
|
|
|
snapshot_preserve_min = "2d";
|
2023-10-04 14:43:57 +02:00
|
|
|
snapshot_preserve = "24h 7d 4w 6m";
|
2023-09-27 18:56:12 +02:00
|
|
|
|
2023-10-09 19:02:16 +02:00
|
|
|
volume."/jc-data" = {
|
|
|
|
snapshot_dir = "/snap";
|
2023-11-15 13:52:21 +01:00
|
|
|
subvolume = ssd-subvolumes;
|
2023-10-04 14:43:57 +02:00
|
|
|
};
|
2023-10-09 19:02:16 +02:00
|
|
|
volume."/mnt/data/jc-data" = {
|
|
|
|
snapshot_dir = "/mnt/data/snap";
|
2023-11-15 13:52:21 +01:00
|
|
|
subvolume = hdd-subvolumes;
|
2023-10-09 19:02:16 +02:00
|
|
|
};
|
2023-10-04 14:43:57 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
"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";
|
|
|
|
|
2023-10-09 19:02:16 +02:00
|
|
|
volume."/jc-data" = {
|
|
|
|
snapshot_dir = "/snap";
|
2023-10-04 14:43:57 +02:00
|
|
|
target = "/mnt/backup/snap";
|
2023-11-15 13:52:21 +01:00
|
|
|
subvolume = ssd-subvolumes;
|
2023-09-27 18:56:12 +02:00
|
|
|
};
|
2023-10-09 19:02:16 +02:00
|
|
|
volume."/mnt/data/jc-data" = {
|
|
|
|
snapshot_dir = "/mnt/data/snap";
|
|
|
|
target = "/mnt/backup/snap2";
|
2023-11-15 13:52:21 +01:00
|
|
|
subvolume = hdd-subvolumes;
|
2023-10-09 19:02:16 +02:00
|
|
|
};
|
2023-09-27 18:56:12 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|