From 7882767a711de110e50aa4f1597710647f286580 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 25 May 2019 00:31:32 +0800 Subject: [PATCH] nixbld: back up more --- nixbld-etc-nixos/backup-module.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nixbld-etc-nixos/backup-module.nix b/nixbld-etc-nixos/backup-module.nix index fc560b0..2d8842c 100644 --- a/nixbld-etc-nixos/backup-module.nix +++ b/nixbld-etc-nixos/backup-module.nix @@ -3,10 +3,24 @@ with lib; let makeBackup = pkgs.writeScript "make-backup" '' #!${pkgs.bash}/bin/bash - ${pkgs.gnutar}/bin/tar cf - /etc/nixos | \ + + set -e + umask 0077 + + DBDUMPDIR=`mktemp -d` + pushd $DBDUMPDIR + + ${config.services.mysql.package}/bin/mysqldump --single-transaction flarum > flarum.sql + ${pkgs.sudo}/bin/sudo -u mattermost ${config.services.postgresql.package}/bin/pg_dump mattermost > mattermost.sql + + ${pkgs.gnutar}/bin/tar cf - /etc/nixos /var/lib/gitea flarum.sql mattermost.sql | \ ${pkgs.bzip2}/bin/bzip2 | \ ${pkgs.gnupg}/bin/gpg --symmetric --batch --passphrase-file /etc/nixos/secret/backup-passphrase | \ ${pkgs.rclone}/bin/rclone rcat --config /etc/nixos/secret/rclone.conf dropbox:backup-`date +%F`.tar.bz2.gpg + + popd + rm -rf $DBDUMPDIR + echo Backup done ''; cfg = config.services.homu;