Remove backup role
This commit is contained in:
parent
0a5c15105b
commit
516e0b5b43
2 changed files with 0 additions and 67 deletions
|
@ -1,3 +0,0 @@
|
|||
== Backup Role
|
||||
|
||||
Creates backup to an external mount with borg backup according to a specified schedule.
|
|
@ -1,64 +0,0 @@
|
|||
# Regular backup role to a separate device
|
||||
{ systemdMount, # Systemd mount name
|
||||
borgArchiveFolder, # Absolute borg root folder
|
||||
keepWithin ? "14d", keepWeekly ? "4", keepMonthly ? "6", keepYearly ? "-1"
|
||||
, schedule ? "13:37", # Systemd Schedule of backup timer
|
||||
}:
|
||||
|
||||
let pkgs = import <nixpkgs> { };
|
||||
in {
|
||||
|
||||
systemd = {
|
||||
services.backup = {
|
||||
description =
|
||||
"Backup of all user data and system configuration with BorgBackup";
|
||||
serviceConfig.Type = "oneshot";
|
||||
path = with pkgs; [ bash borgbackup ];
|
||||
script = ''
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
systemctl start ${systemdMount}
|
||||
|
||||
export BORG_REPO=${borgArchiveFolder} \
|
||||
BORG_BASE_DIR=${borgArchiveFolder}/borg-base-dir
|
||||
|
||||
echo "Backup started at `date`"
|
||||
borg create --exclude /var/backup \
|
||||
--exclude /var/tmp \
|
||||
--exclude /var/cache \
|
||||
$BORG_REPO::{hostname}-{now} \
|
||||
/etc \
|
||||
/home \
|
||||
/root \
|
||||
/var
|
||||
|
||||
sync
|
||||
echo "Backup finished at `date`"
|
||||
|
||||
echo "Backup prune started at `date`"
|
||||
borg prune --prefix '{hostname}-' \
|
||||
--keep-within ${keepWithin} \
|
||||
--keep-weekly ${keepWeekly} \
|
||||
--keep-monthly ${keepMonthly} \
|
||||
--keep-yearly ${keepYearly}
|
||||
sync
|
||||
echo "Backup prune finished at `date`"
|
||||
|
||||
systemctl stop ${systemdMount}
|
||||
'';
|
||||
};
|
||||
|
||||
timers.backup = {
|
||||
description = "Backup Schedule";
|
||||
|
||||
timerConfig = {
|
||||
OnCalendar = schedule;
|
||||
Persistent = "true";
|
||||
};
|
||||
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue