Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/docker minecraft support #30

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ execute-command () {
;;
"RCON"|"rcon") rcon-command "$SCREEN_NAME" "$COMMAND"
;;
"docker-rcon") docker exec "$SCREEN_NAME" rcon-cli "$COMMAND"
;;
esac
fi
}
Expand Down
14 changes: 14 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")"
Expand Down
Loading