made borg use btrfs snapshot
This commit is contained in:
parent
708df543ec
commit
6cee9ab06c
1 changed files with 27 additions and 12 deletions
|
|
@ -1,20 +1,23 @@
|
||||||
{ config, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
let
|
||||||
|
backuppath = "/backup/snapshot";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
services.borgbackup.jobs.default = {
|
services.borgbackup.jobs.default = {
|
||||||
paths = [
|
paths = [
|
||||||
"/etc"
|
"${backuppath}/etc"
|
||||||
"/home"
|
"${backuppath}/home"
|
||||||
"/root"
|
"${backuppath}/root"
|
||||||
"/var"
|
"${backuppath}/var"
|
||||||
];
|
];
|
||||||
exclude = [
|
exclude = [
|
||||||
"*/.cache"
|
"${backuppath}*/.cache"
|
||||||
"/home/*/build"
|
"${backuppath}/home/*/build"
|
||||||
"/var/log"
|
"${backuppath}/var/log"
|
||||||
"/var/lib/nextcloud/data/appdata_ocnc33s4dl6i/preview"
|
"${backuppath}/var/lib/nextcloud/data/appdata_ocnc33s4dl6i/preview"
|
||||||
"/var/lib/postgresql/*/"
|
"${backuppath}/var/lib/postgresql/*/"
|
||||||
"/var/lib/containers"
|
"${backuppath}/var/lib/containers"
|
||||||
"/var/lib/rancher/k3s/agent/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots"
|
"${backuppath}/var/lib/rancher/k3s/agent/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots"
|
||||||
];
|
];
|
||||||
repo = "borg@haus.mc-fucker.cool:/mnt/sdf1/borg/${config.networking.hostName}";
|
repo = "borg@haus.mc-fucker.cool:/mnt/sdf1/borg/${config.networking.hostName}";
|
||||||
compression = "zstd";
|
compression = "zstd";
|
||||||
|
|
@ -22,6 +25,18 @@
|
||||||
environment.BORG_RSH = "ssh -o 'StrictHostKeyChecking=no' -i /root/.ssh/id_borg";
|
environment.BORG_RSH = "ssh -o 'StrictHostKeyChecking=no' -i /root/.ssh/id_borg";
|
||||||
extraCreateArgs = "--verbose --stats";
|
extraCreateArgs = "--verbose --stats";
|
||||||
startAt = "03:00";
|
startAt = "03:00";
|
||||||
|
preHook = ''if [[ -d ${backuppath} ]]; then
|
||||||
|
btrfs subvolume delete ${backuppath}
|
||||||
|
fi
|
||||||
|
btrfs subvolume snapshot / ${backuppath}''; #create snapshot for consistent filesystem
|
||||||
|
postCreate = "btrfs subvolume delete ${backuppath}"; #delete snapshot again
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.borgbackup-job-default = {
|
||||||
|
path = [ pkgs.btrfs-progs ];
|
||||||
|
serviceConfig = {
|
||||||
|
ReadWritePaths = [ "/backup" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue