aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar KamiCreed <9517086+KamiCreed@users.noreply.github.com> 2020-03-25 04:25:45 -0700
committerGravatar KamiCreed <9517086+KamiCreed@users.noreply.github.com> 2020-03-25 04:25:45 -0700
commit631e796812bdd9830fd2fb2f5c05d8323e67b50c (patch)
tree6b82515121c46a0cdf17ad0883e14f173b4146d8
parentac7b43637873f0b4a3d370939343f98e30f95715 (diff)
downloadminecraft-server-tools-631e796812bdd9830fd2fb2f5c05d8323e67b50c.tar.gz
Add automated backup systemd scripts
-rw-r--r--Readme.md11
-rw-r--r--mc-backup.service15
-rw-r--r--mc-backup.timer8
-rw-r--r--minecraft.service2
4 files changed, 34 insertions, 2 deletions
diff --git a/Readme.md b/Readme.md
index b794932..757e394 100644
--- a/Readme.md
+++ b/Readme.md
@@ -45,6 +45,17 @@ Place `minecraft.service` in `/etc/systemd/system/`
and run `systemctl start minecraft` to start once or
`systemctl enable minecraft` to enable autostarting.
+To backup automatically, place or symlink `mc-backup.service` and
+`mc-backup.timer` in `/etc/systemd/system/`. Run the following:
+
+```
+sudo systemctl enable mc-backup.timer
+sudo sytemctl start mc-backup.timer
+```
+
+This wil start the enable the timer upon startup and start the timer
+to run the backup after every interval specified in mc-backup.timer.
+
## Disclaimer
The scripts are provided as-is at no warranty.
diff --git a/mc-backup.service b/mc-backup.service
new file mode 100644
index 0000000..d94656c
--- /dev/null
+++ b/mc-backup.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Automatic backup of Minecraft Server
+
+[Service]
+Type=simple
+User=minecraftuser
+Group=minecraftuser
+ExecStart=/var/minecraft/server.sh backup
+Restart=on-failure
+RestartSec=10s
+StartLimitInterval=10min
+StartLimitBurst=3
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mc-backup.timer b/mc-backup.timer
new file mode 100644
index 0000000..986ff42
--- /dev/null
+++ b/mc-backup.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Backup Minecraft Server every 30 mins
+
+[Timer]
+OnCalendar=*:0/30
+
+[Install]
+WantedBy=multi-user.target
diff --git a/minecraft.service b/minecraft.service
index 2565bc8..5f2a6c4 100644
--- a/minecraft.service
+++ b/minecraft.service
@@ -13,8 +13,6 @@ RestartSec=30s
ExecStart=/var/minecraft/server.sh start
TimeoutStopSec= 180
ExecStop=/var/minecraft/server.sh stop
-StartLimitInterval=10min
-StartLimitBurst=2
[Install]
WantedBy=multi-user.target