cleaning up

This commit is contained in:
hannes 2024-02-20 04:41:48 +01:00
parent 5f92f6fae1
commit ea0b6f8872
3 changed files with 8 additions and 20 deletions

View file

@ -2,4 +2,4 @@
Forgejo but it runs on NixOS.
This includes the CI-Runner now too :3
This includes a configuration.nix for the Forgejo CI-Runner and a backup script that should backup your Forgejo data to a Borg repo of your choice daily.

View file

@ -1,19 +1,19 @@
{config, pkgs, ... }:
# NOTE: For this to work you should use MariaDB as your Forgejo-Database running on the same host. If this is not the case, update this script accordingly.
let
forgejo-borgbackup = pkgs.writeShellScriptBin "forgejo-borgbackup" ''
#!/bin/sh
set -e
#stop forgejo
systemctl stop forgejo.service
# MySQL-Backup
# Dump Forgejo DB
MYSQL_DATABASE="forgejodb"
${pkgs.mariadb}/bin/mysqldump -u root ''${MYSQL_DATABASE} > /borgbackupcache/forgejobackup.sql
# BorgBackup
export BORG_PASSCOMMAND="cat /etc/nixos/borgpassword"
export BORG_REPO="backup@cloud.shibe.pro:/mnt/onedrive/Backups/borg/forgejo"
export BACKUP_NAME="forgejo-$(date +%Y-%m-%d)"
export BORG_REPO=$(cat /etc/nixos/borgrepo)
export BACKUP_NAME="forgejo-$(date +%Y-%m-%d-%H-%M)"
# Add everything to be backed up
${pkgs.borgbackup}/bin/borg create --verbose --filter AME --list --stats --show-rc --compression lz4 --exclude-caches \
@ -21,7 +21,7 @@ let
/var/lib/forgejo/repositories/ \
/var/lib/forgejo/data/ \
/borgbackupcache/forgejobackup.sql
# Remove DB dump
# Delete DB dump
rm /borgbackupcache/forgejobackup.sql
# Start Forgejo again
systemctl start forgejo.service
@ -37,7 +37,7 @@ let
];
# Backup timer
systemd.services.borg-backup = {
description = "Borg Backup for Forgejo and MySQL";
description = "Borg Backup for Forgejo and the Forgejo MySQL Database";
serviceConfig = {
ExecStart = "${forgejo-borgbackup}/bin/forgejo-borgbackup";
User = "root";

View file

@ -8,6 +8,7 @@
imports =
[
./hardware-configuration.nix
# comment in backup.nix for borgbackuping forgejo
./backup.nix
];
@ -26,19 +27,6 @@
# Set your time zone.
time.timeZone = "Europe/Berlin";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# sound.enable = true;
# hardware.pulseaudio.enable = true;
# Define groups because apparently we gotta do that
# users.groups.onedriveaccess = {};
# users.groups.onedriveaccess.gid = 3000;
# Define a user account. Don't forget to set a password with passwd.
users.users.lyn = {
isNormalUser = true;
extraGroups = [ "wheel"];