Compare commits

..

11 commits

Author SHA1 Message Date
9e6ee0ac63
change entrypoint to sh
Some checks failed
CI / test (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / shellcheck (push) Has been cancelled
CI / release (push) Has been cancelled
CI / docker (push) Has been cancelled
2025-03-01 20:20:20 +01:00
Nicolas Chan
8ba2a8c14e Update nix flake 2024-09-11 01:23:50 -07:00
Nicolas Chan
4a4c09e293
Merge pull request #27 from quulah/patch-1
Add rclone to container image
2024-09-11 01:16:41 -07:00
Nicolas Chan
2428e9e940
Merge pull request #30 from rainbowdashlabs/feature/docker-minecraft-support
Feature/docker minecraft support
2024-08-11 01:50:04 -07:00
Nicolas Chan
eea736a762 Add test for docker-rcon 2024-08-11 01:37:26 -07:00
Nicolas Chan
e8254d402c Merge branch 'master' of github.com:nicolaschan/minecraft-backup into feature/docker-minecraft-support 2024-08-11 01:22:37 -07:00
Nicolas Chan
dfb1a1c27d
Merge pull request #32 from nicolaschan/flake
Add flake.nix and update tests
2024-08-11 01:01:10 -07:00
Lilly Tempest
a7318b0de5
Update backup.sh 2023-02-05 11:37:49 +01:00
Lilly Tempest
c3f57f43df
Update README.md 2023-02-05 11:35:44 +01:00
Lilly Tempest
3b055013dd
Update backup.sh 2023-02-05 11:32:08 +01:00
Miika Kankare
12f1fd4b8d
Add rclone to container image 2022-02-12 15:03:23 +02:00
5 changed files with 26 additions and 7 deletions

View file

@ -1,10 +1,10 @@
FROM alpine
LABEL org.opencontainers.image.source=https://github.com/nicolaschan/minecraft-backup
LABEL org.opencontainers.image.source=https://forgejo.nevy.xyz/nev/minecraft-backup
RUN apk add bash coreutils xxd restic util-linux openssh
RUN apk add bash coreutils xxd restic util-linux openssh rclone
WORKDIR /code
COPY ./backup.sh .
ENTRYPOINT ["/code/backup.sh"]
ENTRYPOINT ["/bin/sh", "-c"]

View file

@ -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

View file

@ -266,6 +266,8 @@ execute-command () {
;;
"RCON"|"rcon") rcon-command "$SCREEN_NAME" "$COMMAND"
;;
"docker-rcon") docker exec "$SCREEN_NAME" rcon-cli "$COMMAND"
;;
esac
fi
}

6
flake.lock generated
View file

@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1723175592,
"narHash": "sha256-M0xJ3FbDUc4fRZ84dPGx5VvgFsOzds77KiBMW/mMTnI=",
"lastModified": 1725634671,
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5e0ca22929f3342b19569b21b2f3462f053e497b",
"rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c",
"type": "github"
},
"original": {

View file

@ -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")"