factorio: auto backup the game saves

This commit is contained in:
Leonardo Eugênio 2025-01-29 22:46:04 -03:00
parent c39cf51646
commit 3773beab41

View file

@ -1,4 +1,9 @@
{ config, pkgs, ... }:
{
config,
pkgs,
lib,
...
}:
{
services.factorio = {
enable = true;
@ -15,6 +20,28 @@
wants = [ "network-online.target" ];
};
systemd.services.factorio-backup-save = {
description = "Backup factorio saves";
script = ''
${lib.getExe pkgs.rsync} \
-av \
--chown=lelgenio \
/var/lib/factorio/saves/default.zip \
~lelgenio/Documentos/GameSaves/factorio_saves/space-age-$(date --iso=seconds).zip
'';
serviceConfig.Type = "oneshot";
wantedBy = [ "multi-user.target" ];
};
systemd.timers.factorio-backup-save = {
timerConfig = {
OnCalendar = "*-*-* 18:00:00";
Persistent = true;
Unit = "factorio-backup-save.service";
};
wantedBy = [ "timers.target" ];
};
age.secrets.factorio-settings = {
file = ../../secrets/factorio-settings.age;
mode = "777";