Add ccqcraft-backup service to local server
This commit is contained in:
parent
62054851c5
commit
f98a3f9bd4
|
@ -205,6 +205,7 @@
|
|||
./modules/local-build-service.nix
|
||||
./modules/nginx-reverse-proxy.nix
|
||||
./modules/binary-cache.nix
|
||||
./modules/ccqcraft-backups.nix
|
||||
|
||||
({ pkgs, ... }: {
|
||||
# Override kernel version for zfs
|
||||
|
|
62
modules/ccqcraft-backups.nix
Normal file
62
modules/ccqcraft-backups.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
user = "sleepingbits";
|
||||
host = "sleepingbits.de";
|
||||
path = "~/server/mc/plugins/EasyBackup/backups/";
|
||||
|
||||
fetchTime = "*-*-* 03:00:00";
|
||||
clearTime = "Mon *-*-* 04:00:00";
|
||||
|
||||
in {
|
||||
systemd.services = {
|
||||
ccqcraft-pull-backups = {
|
||||
unitConfig = {
|
||||
Description = ''
|
||||
Pull backups from CCQCraft Minecraft Server via rsync
|
||||
'';
|
||||
After = [ "network.target" ];
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = [
|
||||
''
|
||||
${pkgs.rsync}/bin/rsync -tr --partial --rsh=${pkgs.openssh}/bin/ssh "${user}@${host}:${path}" .''
|
||||
];
|
||||
WorkingDirectory = "/srv/hnd/ccqcraft-backups";
|
||||
};
|
||||
};
|
||||
|
||||
ccqcraft-restart-incremental-backups = {
|
||||
unitConfig = {
|
||||
Description = ''
|
||||
Restart incremental backups for CCQCraft server
|
||||
'';
|
||||
Requires = [ "ccqcraft-pull-backups.service" ];
|
||||
After = [ "network.target" "ccqcraft-pull-backups.service" ];
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart =
|
||||
[ ''${pkgs.openssh}/bin/ssh "${user}@${host}" rm ${path}/*'' ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers = {
|
||||
ccqcraft-pull-backups = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
unitConfig = { Description = "Run CCQCraft Backups every day"; };
|
||||
timerConfig = { OnCalendar = fetchTime; };
|
||||
};
|
||||
|
||||
ccqcraft-restart-incremental-backups = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
unitConfig = {
|
||||
Description = "Restart CCQCraft incremental backups weekly";
|
||||
};
|
||||
timerConfig = { OnCalendar = clearTime; };
|
||||
};
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue