From 6550ad5302b04476adb2c1b73abcec9321428f63 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 31 Aug 2023 14:15:53 +0800 Subject: [PATCH] nixbld: debloat backups --- nixbld-etc-nixos/backup-module.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nixbld-etc-nixos/backup-module.nix b/nixbld-etc-nixos/backup-module.nix index e95c7d57..8f14103d 100644 --- a/nixbld-etc-nixos/backup-module.nix +++ b/nixbld-etc-nixos/backup-module.nix @@ -1,6 +1,17 @@ { config, pkgs, lib, ... }: with lib; let + excludePaths = [ + "/var/lib/gitea/repositories/*/*.git/archives" + "/var/lib/gitea/data/repo-archive" + "/var/lib/gitea/data/indexers" + "/var/vmail/m-labs.hk/js" + "/var/lib/afws/.cache" + "/var/lib/mattermost/data/2019*" + "/var/lib/mattermost/data/2020*" + "/var/lib/mattermost/data/2021*" + "/var/lib/mattermost/data/2022*" + ]; makeBackup = pkgs.writeScript "make-backup" '' #!${pkgs.bash}/bin/bash @@ -16,7 +27,7 @@ let ${pkgs.sudo}/bin/sudo -u mattermost ${config.services.postgresql.package}/bin/pg_dump mattermost > mattermost.sql ${pkgs.sudo}/bin/sudo -u rt ${config.services.postgresql.package}/bin/pg_dump rt5 > rt.sql - ${pkgs.gnutar}/bin/tar cf - --exclude "/var/lib/gitea/repositories/*/*.git/archives" --exclude "/var/lib/gitea/data/repo-archive" --exclude "/var/lib/afws/.cache" /etc/nixos /var/vmail /var/lib/hedgedoc /var/lib/gitea /var/lib/afws /var/lib/mattermost/data flarum.sql mattermost.sql rt.sql | \ + ${pkgs.gnutar}/bin/tar cf - ${lib.concatMapStringsSep " " (p: "--exclude \"${p}\"") excludePaths} /etc/nixos /var/vmail /var/lib/hedgedoc /var/lib/gitea /var/lib/afws /var/lib/mattermost/data flarum.sql mattermost.sql rt.sql | \ ${pkgs.bzip2}/bin/bzip2 | \ ${pkgs.gnupg}/bin/gpg --symmetric --batch --passphrase-file /etc/nixos/secret/backup-passphrase > /home/backupdl/$FILENAME