Skip to content

Instantly share code, notes, and snippets.

@Lartza
Last active December 7, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lartza/533c4aca60dec049967693fd6b10c7df to your computer and use it in GitHub Desktop.
Save Lartza/533c4aca60dec049967693fd6b10c7df to your computer and use it in GitHub Desktop.
RLCraft backups
[Unit]
Description=oneshot backup for rlcraft
# This can be problematic
#Requires=rlcraft.service
[Service]
Type=oneshot
User=lartza
Group=lartza
WorkingDirectory=/home/lartza
ExecStart=/usr/bin/bash /home/lartza/rlcraft-backup.sh
[Install]
WantedBy=multi-user.target
#!/bin/sh
cd /home/lartza
# Setting this, so the repo does not need to be given on the commandline:
export BORG_REPO=/home/lartza/rlcraft-borg
mcrcon -s -c -H localhost -p <RCON.PASSWORD> "say Starting world backup, world saving disabled" || true
mcrcon -s -c -H localhost -p <RCON.PASSWORD> save-off || true
mcrcon -s -c -H localhost -p <RCON.PASSWORD> save-all || true
sleep 5
borg create \
--exclude-caches \
$BORG_REPO::'rlcraft-world-{now}' \
/home/lartza/RLCraft/world \
mcrcon -s -c -H localhost -p <RCON.PASSWORD> save-on || true
mcrcon -s -c -H localhost -p <RCON.PASSWORD> "say Backup finished, world saving enabled" || true
[Unit]
Description=rlcraft backup timer
[Timer]
OnCalendar=*-*-* 1/2:00:00
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment