mirror of
https://codeberg.org/privacy1st/nix-git
synced 2025-02-11 08:50:59 +01:00
btrbk: config update and zstd compression
This commit is contained in:
parent
f30b5697ab
commit
239354ab9f
@ -13,7 +13,6 @@ let
|
|||||||
"changedetection.p1st.de" = {};
|
"changedetection.p1st.de" = {};
|
||||||
"cloud.privacy1st.de" = {};
|
"cloud.privacy1st.de" = {};
|
||||||
"cloud.fykml.eu" = {};
|
"cloud.fykml.eu" = {};
|
||||||
"git.privacy1st.de" = {};
|
|
||||||
"mastodon-toot-follower.privacy1st.de" = {};
|
"mastodon-toot-follower.privacy1st.de" = {};
|
||||||
"money.p1st.de" = {};
|
"money.p1st.de" = {};
|
||||||
"music.privacy1st.de" = {};
|
"music.privacy1st.de" = {};
|
||||||
@ -26,15 +25,16 @@ let
|
|||||||
"arch.p1st.de" = {};
|
"arch.p1st.de" = {};
|
||||||
"cloud.privacy1st.de" = {};
|
"cloud.privacy1st.de" = {};
|
||||||
"cloud.fykml.eu" = {};
|
"cloud.fykml.eu" = {};
|
||||||
|
"git.privacy1st.de" = {};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# TODO: Enable lz4 when yodaHedgehog no longer has direct LAN connection.
|
# TODO: Disable zstd if yodaHedgehog has direct LAN connection to yodaHedgehog.
|
||||||
yoda.btrbkBackups = [
|
yoda.btrbkBackups = [
|
||||||
{
|
{
|
||||||
instance = "remote-backup-ssd";
|
instance = "remote-backup-ssd";
|
||||||
enable = false;
|
enable = false;
|
||||||
lz4 = false;
|
zstd = true;
|
||||||
ssh_identity = "/root/.ssh/rootNas_ed25519";
|
ssh_identity = "/root/.ssh/rootNas_ed25519";
|
||||||
volume = "ssh://rootNas/jc-data";
|
volume = "ssh://rootNas/jc-data";
|
||||||
snapshot_dir = "/snap";
|
snapshot_dir = "/snap";
|
||||||
@ -44,7 +44,7 @@ in
|
|||||||
{
|
{
|
||||||
instance = "remote-backup-hdd";
|
instance = "remote-backup-hdd";
|
||||||
enable = false;
|
enable = false;
|
||||||
lz4 = false;
|
zstd = true;
|
||||||
ssh_identity = "/root/.ssh/rootNas_ed25519";
|
ssh_identity = "/root/.ssh/rootNas_ed25519";
|
||||||
volume = "ssh://rootNas/mnt/data/jc-data";
|
volume = "ssh://rootNas/mnt/data/jc-data";
|
||||||
snapshot_dir = "/mnt/data/snap2";
|
snapshot_dir = "/mnt/data/snap2";
|
||||||
|
@ -56,6 +56,8 @@ in
|
|||||||
opensmtpd
|
opensmtpd
|
||||||
# Provides `btrbk`
|
# Provides `btrbk`
|
||||||
btrbk
|
btrbk
|
||||||
|
# Provides `zstd` required by `btrbk`.
|
||||||
|
zstd
|
||||||
# Provides `sudo` required by `btrbk`.
|
# Provides `sudo` required by `btrbk`.
|
||||||
# Alternatively we could configure `btrbk` to use the "btrfs-progs" instead of the "btrfs-progs-sudo" backend. But the `btrbk` NixOS module has no option for this.
|
# Alternatively we could configure `btrbk` to use the "btrfs-progs" instead of the "btrfs-progs-sudo" backend. But the `btrbk` NixOS module has no option for this.
|
||||||
sudo
|
sudo
|
||||||
|
@ -5,7 +5,6 @@ let
|
|||||||
"changedetection.p1st.de" = {};
|
"changedetection.p1st.de" = {};
|
||||||
"cloud.privacy1st.de" = {};
|
"cloud.privacy1st.de" = {};
|
||||||
"cloud.fykml.eu" = {};
|
"cloud.fykml.eu" = {};
|
||||||
"git.privacy1st.de" = {};
|
|
||||||
"mastodon-toot-follower.privacy1st.de" = {};
|
"mastodon-toot-follower.privacy1st.de" = {};
|
||||||
"money.p1st.de" = {};
|
"money.p1st.de" = {};
|
||||||
"music.privacy1st.de" = {};
|
"music.privacy1st.de" = {};
|
||||||
@ -18,6 +17,7 @@ let
|
|||||||
"arch.p1st.de" = {};
|
"arch.p1st.de" = {};
|
||||||
"cloud.privacy1st.de" = {};
|
"cloud.privacy1st.de" = {};
|
||||||
"cloud.fykml.eu" = {};
|
"cloud.fykml.eu" = {};
|
||||||
|
"git.privacy1st.de" = {};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -367,7 +367,7 @@ sudo btrbk -c ~/btrbk.cfg list
|
|||||||
# Configuration options for btrbk. Nested attrsets translate to subsections.
|
# Configuration options for btrbk. Nested attrsets translate to subsections.
|
||||||
settings = {
|
settings = {
|
||||||
timestamp_format = "long";
|
timestamp_format = "long";
|
||||||
stream_compress = "lz4";
|
stream_compress = "zstd";
|
||||||
|
|
||||||
snapshot_preserve_min = "2d";
|
snapshot_preserve_min = "2d";
|
||||||
snapshot_preserve = "24h 7d 4w 6m";
|
snapshot_preserve = "24h 7d 4w 6m";
|
||||||
@ -396,7 +396,7 @@ Another remote backup server periodically pulls snapshots to create remote backu
|
|||||||
```shell
|
```shell
|
||||||
cat > ~/btrbk.cfg <<'EOF'
|
cat > ~/btrbk.cfg <<'EOF'
|
||||||
timestamp_format long
|
timestamp_format long
|
||||||
stream_compress lz4
|
stream_compress zstd
|
||||||
ssh_identity /mnt/backup/rootNas_ed25519
|
ssh_identity /mnt/backup/rootNas_ed25519
|
||||||
|
|
||||||
# Create backups.
|
# Create backups.
|
||||||
@ -417,7 +417,6 @@ volume ssh://rootNas/jc-data
|
|||||||
subvolume blogger.privacy1st.de
|
subvolume blogger.privacy1st.de
|
||||||
subvolume changedetection.p1st.de
|
subvolume changedetection.p1st.de
|
||||||
subvolume cloud.privacy1st.de
|
subvolume cloud.privacy1st.de
|
||||||
subvolume git.privacy1st.de
|
|
||||||
subvolume mastodon-toot-follower.privacy1st.de
|
subvolume mastodon-toot-follower.privacy1st.de
|
||||||
subvolume money.p1st.de
|
subvolume money.p1st.de
|
||||||
subvolume music.privacy1st.de
|
subvolume music.privacy1st.de
|
||||||
@ -430,5 +429,6 @@ volume ssh://rootNas/mnt/data/jc-data
|
|||||||
target /mnt/backup/snap2
|
target /mnt/backup/snap2
|
||||||
subvolume cloud.privacy1st.de
|
subvolume cloud.privacy1st.de
|
||||||
subvolume cloud.fykml.eu
|
subvolume cloud.fykml.eu
|
||||||
|
subvolume git.privacy1st.de
|
||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
@ -18,8 +18,8 @@ in
|
|||||||
# Can be used to disable timer.
|
# Can be used to disable timer.
|
||||||
#enable = false;
|
#enable = false;
|
||||||
# Optional.
|
# Optional.
|
||||||
# If this is `true` and `volume` starts with `ssh://`, `lz4` transport compression is enabled.
|
# If this is `true` and `volume` starts with `ssh://`, `zstd` transport compression is enabled.
|
||||||
lz4 = true;
|
zstd = true;
|
||||||
# Optional.
|
# Optional.
|
||||||
#ssh_identity = /root/.ssh/rootNas_ed25519;
|
#ssh_identity = /root/.ssh/rootNas_ed25519;
|
||||||
volume = "/jc-data";
|
volume = "/jc-data";
|
||||||
@ -41,6 +41,8 @@ in
|
|||||||
# lib.attrsets.mergeAttrsList:
|
# lib.attrsets.mergeAttrsList:
|
||||||
# https://github.com/NixOS/nixpkgs/blob/54f00576aa6139a9d54062d0edc2fb31423f0ffb/lib/attrsets.nix#L786
|
# https://github.com/NixOS/nixpkgs/blob/54f00576aa6139a9d54062d0edc2fb31423f0ffb/lib/attrsets.nix#L786
|
||||||
config = {
|
config = {
|
||||||
|
# In case a btrbk instance uses stream_compress with zstd.
|
||||||
|
services.btrbk.extraPackages = [ pkgs.zstd ];
|
||||||
services.btrbk.instances =
|
services.btrbk.instances =
|
||||||
# Merge list of attr sets into one attr set.
|
# Merge list of attr sets into one attr set.
|
||||||
attrsets.mergeAttrsList (
|
attrsets.mergeAttrsList (
|
||||||
@ -53,7 +55,8 @@ in
|
|||||||
onCalendar = if (x.enable or true) then "12:05" else null;
|
onCalendar = if (x.enable or true) then "12:05" else null;
|
||||||
settings = {
|
settings = {
|
||||||
timestamp_format = "long";
|
timestamp_format = "long";
|
||||||
stream_compress = mkIf ((x.lz4 or false) && strings.hasPrefix "ssh://" x.volume) "lz4";
|
stream_compress = mkIf ((x.zstd or false) && strings.hasPrefix "ssh://" x.volume) "zstd";
|
||||||
|
stream_compress_level = mkIf ((x.zstd or false) && strings.hasPrefix "ssh://" x.volume) "9";
|
||||||
ssh_identity = mkIf (x?ssh_identity) x.ssh_identity;
|
ssh_identity = mkIf (x?ssh_identity) x.ssh_identity;
|
||||||
|
|
||||||
# Create backups.
|
# Create backups.
|
||||||
|
@ -17,6 +17,22 @@
|
|||||||
./backup.nix
|
./backup.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# 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
|
||||||
|
];
|
||||||
|
|
||||||
services.btrbk = {
|
services.btrbk = {
|
||||||
# Lowest scheduling priority.
|
# Lowest scheduling priority.
|
||||||
niceness = 19;
|
niceness = 19;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user