cleaning up
This commit is contained in:
parent
4e1d97793b
commit
a5bcdc2180
3 changed files with 8 additions and 20 deletions
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
Forgejo but it runs on NixOS.
|
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.
|
||||||
|
|
12
backup.nix
12
backup.nix
|
@ -1,19 +1,19 @@
|
||||||
{config, pkgs, ... }:
|
{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
|
let
|
||||||
forgejo-borgbackup = pkgs.writeShellScriptBin "forgejo-borgbackup" ''
|
forgejo-borgbackup = pkgs.writeShellScriptBin "forgejo-borgbackup" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
#stop forgejo
|
#stop forgejo
|
||||||
systemctl stop forgejo.service
|
systemctl stop forgejo.service
|
||||||
# MySQL-Backup
|
# Dump Forgejo DB
|
||||||
MYSQL_DATABASE="forgejodb"
|
MYSQL_DATABASE="forgejodb"
|
||||||
${pkgs.mariadb}/bin/mysqldump -u root ''${MYSQL_DATABASE} > /borgbackupcache/forgejobackup.sql
|
${pkgs.mariadb}/bin/mysqldump -u root ''${MYSQL_DATABASE} > /borgbackupcache/forgejobackup.sql
|
||||||
# BorgBackup
|
# BorgBackup
|
||||||
export BORG_PASSCOMMAND="cat /etc/nixos/borgpassword"
|
export BORG_PASSCOMMAND="cat /etc/nixos/borgpassword"
|
||||||
export BORG_REPO="backup@cloud.shibe.pro:/mnt/onedrive/Backups/borg/forgejo"
|
export BORG_REPO=$(cat /etc/nixos/borgrepo)
|
||||||
export BACKUP_NAME="forgejo-$(date +%Y-%m-%d)"
|
export BACKUP_NAME="forgejo-$(date +%Y-%m-%d-%H-%M)"
|
||||||
|
|
||||||
# Add everything to be backed up
|
# Add everything to be backed up
|
||||||
${pkgs.borgbackup}/bin/borg create --verbose --filter AME --list --stats --show-rc --compression lz4 --exclude-caches \
|
${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/repositories/ \
|
||||||
/var/lib/forgejo/data/ \
|
/var/lib/forgejo/data/ \
|
||||||
/borgbackupcache/forgejobackup.sql
|
/borgbackupcache/forgejobackup.sql
|
||||||
# Remove DB dump
|
# Delete DB dump
|
||||||
rm /borgbackupcache/forgejobackup.sql
|
rm /borgbackupcache/forgejobackup.sql
|
||||||
# Start Forgejo again
|
# Start Forgejo again
|
||||||
systemctl start forgejo.service
|
systemctl start forgejo.service
|
||||||
|
@ -37,7 +37,7 @@ let
|
||||||
];
|
];
|
||||||
# Backup timer
|
# Backup timer
|
||||||
systemd.services.borg-backup = {
|
systemd.services.borg-backup = {
|
||||||
description = "Borg Backup for Forgejo and MySQL";
|
description = "Borg Backup for Forgejo and the Forgejo MySQL Database";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${forgejo-borgbackup}/bin/forgejo-borgbackup";
|
ExecStart = "${forgejo-borgbackup}/bin/forgejo-borgbackup";
|
||||||
User = "root";
|
User = "root";
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
# comment in backup.nix for borgbackuping forgejo
|
||||||
./backup.nix
|
./backup.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -26,19 +27,6 @@
|
||||||
# Set your time zone.
|
# Set your time zone.
|
||||||
time.timeZone = "Europe/Berlin";
|
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 = {
|
users.users.lyn = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel"];
|
extraGroups = [ "wheel"];
|
||||||
|
|
Loading…
Reference in a new issue