helm/hosts/ao/modules/backup.nix

51 lines
1.6 KiB
Nix
Raw Permalink Normal View History

2021-03-11 21:46:33 -08:00
{ config, lib, pkgs, ... }:
{
services.vaultwarden.backupDir = "/backups/vaultwarden";
2021-03-11 21:46:33 -08:00
services.gitea.dump.enable = true;
services.gitea.dump.backupDir = "/backups/gitea";
system.activationScripts.createBackupDir = ''
mkdir -m 750 -p "${config.services.vaultwarden.backupDir}" || true
2021-03-11 21:46:33 -08:00
mkdir -m 750 -p "${config.services.gitea.dump.backupDir}" || true
chown vaultwarden:vaultwarden "${config.services.vaultwarden.backupDir}"
2021-03-11 21:46:33 -08:00
chown git:gitea "${config.services.gitea.dump.backupDir}"
'';
# systemd = {
# services.backups = {
# description = "Backup /backups to NAS";
# wants = [ "usr-drive.mount" ];
# path = [ pkgs.rsync ];
# environment = {
# SRC_DIR = "/backups";
# DEST_DIR = "/usr/drive";
# };
# script = ''
# if [[ -d "$1" && -d "$2" ]]; then
# echo "---- BACKUPING UP $1 TO $2 ----"
# rsync -rlptPJ --delete --delete-after \
# --chmod=go= \
# --chown=hlissner:users \
# --exclude=lost+found/ \
# --exclude=@eaDir/ \
# --include=.git/ \
# --filter=':- .gitignore' \
# --filter=':- $XDG_CONFIG_HOME/git/ignore' \
# "$SRC_DIR/" "$DEST_DIR"
# fi
# '';
# serviceConfig = {
# Type = "oneshot";
# Nice = 19;
# IOSchedulingClass = "idle";
# };
# };
# timers.backups = {
# wantedBy = [ "timers.target" ];
# partOf = [ "backups.service" ];
# timerConfig.OnCalendar = "*-*-* 03:00:00";
# timerConfig.Persistent = true;
# };
# };
}