1
0
Fork 0

nixbld: back up more

This commit is contained in:
Sebastien Bourdeauducq 2019-05-25 00:31:32 +08:00
parent 42fac07c85
commit 7882767a71
1 changed files with 15 additions and 1 deletions

View File

@ -3,10 +3,24 @@ with lib;
let let
makeBackup = pkgs.writeScript "make-backup" '' makeBackup = pkgs.writeScript "make-backup" ''
#!${pkgs.bash}/bin/bash #!${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.bzip2}/bin/bzip2 | \
${pkgs.gnupg}/bin/gpg --symmetric --batch --passphrase-file /etc/nixos/secret/backup-passphrase | \ ${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 ${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 echo Backup done
''; '';
cfg = config.services.homu; cfg = config.services.homu;