From 3b055013ddc47dbda6f64524a65e305f0e713ea5 Mon Sep 17 00:00:00 2001 From: Lilly Tempest <46890129+rainbowdashlabs@users.noreply.github.com> Date: Sun, 5 Feb 2023 11:32:08 +0100 Subject: [PATCH 1/4] Update backup.sh --- backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backup.sh b/backup.sh index d3c0827..162e08d 100755 --- a/backup.sh +++ b/backup.sh @@ -266,6 +266,9 @@ execute-command () { ;; "RCON"|"rcon") rcon-command "$SCREEN_NAME" "$COMMAND" ;; + "docker-rcon") docker exec "$SCREEN_NAME" rcon-cli "$COMMAND" + ;; + esac fi } From c3f57f43dfc834b7ba49baa55e3fc7bb76518bd2 Mon Sep 17 00:00:00 2001 From: Lilly Tempest <46890129+rainbowdashlabs@users.noreply.github.com> Date: Sun, 5 Feb 2023 11:35:44 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed7bdcc..1ccde05 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,9 @@ docker run \ -v /home/user/server/world:/mnt/server \ -v /mnt/storage/backups:/mnt/backups \ ghcr.io/nicolaschan/minecraft-backup -c -i /mnt/server -o /mnt/backups -s server-host:25575:secret -w rcon + +# Using itzg/docker-minecraft-server container and rcon cli +./backup.sh -c -i /home/user/server/world -o /mnt/storage/backups -s container-name -w docker-rcon ``` This will show chat messages (`-c`) and save a backup of `/home/user/server/world` into `/mnt/storage/backups` using the default thinning deletion policy for old backups. @@ -64,7 +67,7 @@ Command line options: -p Prefix that shows in Minecraft chat (default: Backup) -q Suppress warnings -r Restic repo name (if using restic) --s Screen name, tmux session name, or hostname:port:password for RCON +-s Screen name, tmux session name, hostname:port:password for RCON or [container name](https://github.com/itzg/docker-minecraft-server) for docker-rcon -t Enable lock file (lock file not used by default) -u Lock file timeout seconds (empty = unlimited) -v Verbose mode From a7318b0de5f78fcb6f96283656e57689fb400497 Mon Sep 17 00:00:00 2001 From: Lilly Tempest <46890129+rainbowdashlabs@users.noreply.github.com> Date: Sun, 5 Feb 2023 11:37:49 +0100 Subject: [PATCH 3/4] Update backup.sh --- backup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/backup.sh b/backup.sh index 162e08d..af4ad58 100755 --- a/backup.sh +++ b/backup.sh @@ -268,7 +268,6 @@ execute-command () { ;; "docker-rcon") docker exec "$SCREEN_NAME" rcon-cli "$COMMAND" ;; - esac fi } From eea736a762cde6f46494366eecd2ff7b603ed27b Mon Sep 17 00:00:00 2001 From: Nicolas Chan Date: Sun, 11 Aug 2024 01:37:26 -0700 Subject: [PATCH 4/4] Add test for docker-rcon --- test/test.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test.sh b/test/test.sh index 3690347..42a2991 100755 --- a/test/test.sh +++ b/test/test.sh @@ -379,6 +379,20 @@ test-rcon-interface-not-running () { assertContains "$OUTPUT" "Could not connect" } +test-docker-rcon () { + CONTAINER="$(docker run -d -e EULA=TRUE docker.io/itzg/minecraft-server)" + while ! docker exec "$CONTAINER" grep 'RCON running on 0.0.0.0:25575' /data/logs/latest.log; do + sleep 0.1 + done + TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01")" + ./backup.sh -w docker-rcon -i "$TEST_TMP/server/world" -o "$TEST_TMP/backups" -s "$CONTAINER" -f "$TIMESTAMP" + OUTPUT="$(docker exec "$CONTAINER" cat /data/logs/latest.log)" + docker rm -f "$CONTAINER" + assertContains "$OUTPUT" "[Rcon: Automatic saving is now disabled]" + assertContains "$OUTPUT" "[Rcon: Automatic saving is now enabled]" + assertContains "$OUTPUT" "[Rcon: Saved the game]" +} + test-sequential-delete () { for i in $(seq 0 20); do TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01 +$i hour")"