import fix
This commit is contained in:
parent
3dd7e78b20
commit
22c30750fc
2 changed files with 1 additions and 30 deletions
|
@ -1,30 +0,0 @@
|
||||||
{config, pkgs, ... }:
|
|
||||||
|
|
||||||
|
|
||||||
let
|
|
||||||
forgejo-borgbackup = pkgs.writeShellScriptBin "forgejo-borgbackup" ''
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
#stop forgejo
|
|
||||||
systemctl stop forgejo.service
|
|
||||||
# MySQL-Backup
|
|
||||||
MYSQL_OPTION_FILE="/etc/nixos/dbauth.cnf"
|
|
||||||
MYSQL_DATABASE="forgejodb"
|
|
||||||
mysqldump --defaults-file="${MYSQL_OPTION_FILE}" $MYSQL_DATABASE > /borgbackupcache/forgejobackup.sql
|
|
||||||
# BorgBackup
|
|
||||||
export BORG_REPO="ssh://backup@cloud.shibe.pro://mnt/onedrive/Backups/borg"
|
|
||||||
export BACKUP_NAME="forgejo-$(date +%Y-%m-%d)"
|
|
||||||
|
|
||||||
# Add everything to be backed up
|
|
||||||
${pkgs.borgbackup}/bin/borg create --verbose --filter AME --list --stats --show-rc --compression lz4 --exclude-caches \
|
|
||||||
$BORG_REPO::$BACKUP_NAME \
|
|
||||||
/var/lib/forgejo/repositories/ \
|
|
||||||
/var/lib/forgejo/data/ \
|
|
||||||
/borgbackupcache/forgejobackup.sql
|
|
||||||
# Remove DB dump
|
|
||||||
rm /borgbackupcache/forgejobackup.sql
|
|
||||||
# Start Forgejo again
|
|
||||||
systemctl start forgejo.service
|
|
||||||
# Prune old backups
|
|
||||||
${pkgs.borgbackup}/bin/borg prune --list $BORG_REPO --prefix 'forgejo-' --show-rc --keep-daily=7 --keep-weekly=4 --keep-monthly=6
|
|
||||||
'';
|
|
|
@ -8,6 +8,7 @@
|
||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
./backup.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# Enable Flakes and the new command-line tool
|
# Enable Flakes and the new command-line tool
|
||||||
|
|
Loading…
Reference in a new issue