2023-11-16 11:32:15 +01: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
|
|
|
|
#
|
|
|
|
# If onCalendar is set to `null`, one can manually execute btrbk with
|
|
|
|
# sudo systemctl start btrbk-<instance-name>.service
|
|
|
|
|
|
|
|
# Print generated systemd unit file
|
|
|
|
# cat "$(systemctl show -P FragmentPath btrbk-<instance-name>.service)"
|
|
|
|
# #=> 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
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
2023-11-17 15:06:01 +01:00
|
|
|
imports = [
|
|
|
|
./snapshot.nix
|
|
|
|
./backup.nix
|
|
|
|
];
|
|
|
|
|
2025-02-08 15:14:33 +01:00
|
|
|
# Compression
|
|
|
|
#
|
|
|
|
# `btrbk` can be configured to either
|
|
|
|
# - compress the BTRFS data stream itself
|
|
|
|
# - or to enable SSH compression
|
|
|
|
#
|
|
|
|
# The latter supports only ZLIB (LZ77) compression, see https://www.ietf.org/rfc/rfc4253.txt
|
|
|
|
# Thus, we choose the first option instead.
|
|
|
|
#
|
|
|
|
# lz4 is a good option, but zstd-9 seems to be better in the mean time.
|
|
|
|
#
|
|
|
|
# Install the compression package so that other hosts can pull compressed snapshots from us.
|
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.zstd
|
|
|
|
];
|
|
|
|
|
2023-09-27 18:56:12 +02:00
|
|
|
services.btrbk = {
|
|
|
|
# Lowest scheduling priority.
|
|
|
|
niceness = 19;
|
2023-11-17 15:06:01 +01:00
|
|
|
# The `instances` option is set by `./snapshot.nix` and `./backup.nix`.
|
2023-09-27 18:56:12 +02:00
|
|
|
};
|
|
|
|
}
|