Solution de sauvegarde borg

This commit is contained in:
nyanloutre 2018-05-27 18:41:47 +02:00
parent 44670ffbcf
commit 8e81d5398c
2 changed files with 69 additions and 34 deletions

View File

@ -17,23 +17,13 @@
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/BAA3-0464";
fsType = "vfat";
};
fileSystems."/mnt/coreos_drive" =
{ device = "/dev/disk/by-uuid/bf1f6234-7f65-48a2-b7f8-4eab532eed90";
fsType = "ext4";
};
fileSystems."/var/lib/radarr" =
{ device = "loutrepool/var/radarr";
fsType = "zfs";
};
fileSystems."/var/lib/slimserver" =
{ device = "loutrepool/var/slimserver";
fileSystems."/var/lib/acme" =
{ device = "loutrepool/var/acme";
fsType = "zfs";
};
@ -42,13 +32,23 @@
fsType = "zfs";
};
fileSystems."/var/lib/matrix-synapse" =
{ device = "loutrepool/var/matrix-synapse";
fsType = "zfs";
};
fileSystems."/var/lib/radarr" =
{ device = "loutrepool/var/radarr";
fsType = "zfs";
};
fileSystems."/var/lib/grafana" =
{ device = "loutrepool/var/grafana";
fsType = "zfs";
};
fileSystems."/var/lib/emby/ProgramData-Server" =
{ device = "loutrepool/var/emby";
fileSystems."/var/lib/slimserver" =
{ device = "loutrepool/var/slimserver";
fsType = "zfs";
};
@ -57,13 +57,8 @@
fsType = "zfs";
};
fileSystems."/var/lib/duplicati" =
{ device = "loutrepool/var/duplicati";
fsType = "zfs";
};
fileSystems."/mnt/medias" =
{ device = "loutrepool/medias";
fileSystems."/var/lib/postgresql" =
{ device = "loutrepool/var/postgresql";
fsType = "zfs";
};
@ -72,8 +67,8 @@
fsType = "zfs";
};
fileSystems."/var/lib/acme" =
{ device = "loutrepool/var/acme";
fileSystems."/var/lib/emby/ProgramData-Server" =
{ device = "loutrepool/var/emby";
fsType = "zfs";
};
@ -82,13 +77,8 @@
fsType = "zfs";
};
fileSystems."/var/vmail" =
{ device = "loutrepool/var/vmail";
fsType = "zfs";
};
fileSystems."/var/dkim" =
{ device = "loutrepool/var/dkim";
fileSystems."/mnt/medias" =
{ device = "loutrepool/medias";
fsType = "zfs";
};
@ -97,18 +87,28 @@
fsType = "zfs";
};
fileSystems."/var/vmail" =
{ device = "loutrepool/var/vmail";
fsType = "zfs";
};
fileSystems."/var/lib/sonarr" =
{ device = "loutrepool/var/sonarr";
fsType = "zfs";
};
fileSystems."/var/lib/postgresql" =
{ device = "loutrepool/var/postgresql";
fileSystems."/var/dkim" =
{ device = "loutrepool/var/dkim";
fsType = "zfs";
};
fileSystems."/var/lib/matrix-synapse" =
{ device = "loutrepool/var/matrix-synapse";
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/BAA3-0464";
fsType = "vfat";
};
fileSystems."/mnt/backup" =
{ device = "backup";
fsType = "zfs";
};

View File

@ -207,6 +207,41 @@ in
localhost = "hostaddr=127.0.0.1 port=5432 dbname=postgres";
};
services.borgbackup.jobs = {
loutre = {
paths = [
"/var/lib/transmission"
"/var/vmail"
"/var/dkim"
"/var/lib/grafana"
"/var/lib/matrix-synapse"
"/var/lib/postgresql/.zfs/snapshot/borgsnap"
"/var/lib/syncthing"
"/mnt/medias/musique"
"/mnt/medias/torrent/lidarr"
"/mnt/medias/torrent/musique"
];
repo = "/mnt/backup/borg";
encryption = {
mode = "repokey-blake2";
passCommand = "cat /root/borg/medias_encryption_pass";
};
startAt = "weekly";
prune.keep = {
within = "1d";
weekly = 4;
monthly = 12;
};
preHook = "${pkgs.zfs}/bin/zfs snapshot loutrepool/var/postgresql@borgsnap";
postHook = ''
${pkgs.zfs}/bin/zfs destroy loutrepool/var/postgresql@borgsnap
if [[ $exitStatus == 0 ]]; then
${pkgs.rclone}/bin/rclone --config /root/.config/rclone/rclone.conf sync -v $BORG_REPO loutre_ovh:loutre
fi
'';
};
};
services.site-musique.enable = true;
services.site-musique.port = musique_port;
services.site-musique.domaine = "musique.${domaine}";