Last active
October 26, 2021 18:06
-
-
Save AugustMiller/363d7f360ca72a9cb46daa179622a270 to your computer and use it in GitHub Desktop.
Minecraft Bedrock Server ("BDS") configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
timestamp=$(date -Iseconds) | |
bedrock="/home/minecraft/bedrock" | |
serverlogfile="$bedrock/bin/current/log.txt" | |
lockfile="$bedrock/backups/lock" | |
# Test if our lock file is in place. We don't want concurrent backups running: | |
if [ -f $lockfile ]; then | |
exit 1 | |
fi | |
# Create a lockfile for this backup: | |
touch $lockfile | |
# Notify server that a backup is starting: | |
screen -S minecraft -p bedrock -X stuff 'say §6Starting backup...\n' | |
# Pause modifications to the world: | |
screen -S minecraft -p bedrock -X stuff 'save hold\n' | |
# Wait for hold confirmation: | |
finished="" | |
while [[ $finished != *"Data saved."* ]]; do | |
screen -S minecraft -p bedrock -X stuff 'say Waiting for world lock...\n' | |
sleep 5s | |
screen -S minecraft -p bedrock -X stuff 'save query\n' | |
finished=$(tail -n 4 $serverlogfile) | |
done | |
# Let users know the world is locked: | |
screen -S minecraft -p bedrock -X stuff 'say §cThe world is temporarily locked while the backup is captured!\n' | |
# Copy World: | |
rsync -rvz "$bedrock/bin/current/worlds" "$bedrock/backups/worlds-$timestamp" | |
# Unlink + re-link latest copy for easy reference: | |
rm -f "$bedrock/backups/latest" | |
ln -s "$bedrock/backups/worlds-$timestamp" "$bedrock/backups/latest" | |
# Unlock: | |
screen -S minecraft -p bedrock -X stuff 'save resume\n' | |
# Clean up lockfile: | |
rm -f $lockfile | |
# Notify server of completed backup: | |
screen -S minecraft -p bedrock -X stuff 'say §aBackup complete!\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
├── backup.sh | |
├── backups | |
│ ├── latest -> /home/minecraft/bedrock/backups/worlds-2020-04-04T19:30:01+00:00 | |
│ ├── lock (When a backup is running) | |
│ ├── worlds-2020-04-03T23:31:10+00:00 | |
│ ├── worlds-2020-04-03T23:31:10+00:00 | |
│ ├── worlds-2020-04-04T00:00:01+00:00 | |
│ ├── worlds-2020-04-04T18:30:01+00:00 | |
│ ├── worlds-2020-04-04T19:00:01+00:00 | |
│ ├── worlds-2020-04-04T19:30:01+00:00 | |
│ └── ... | |
├── bin | |
│ ├── 1.14.32.1 | |
│ └── current -> 1.14.32.1 | |
│ └── (Lots of stuff, but most importantly: log.txt set up with `logrotate.d`) | |
├── papyrus | |
│ ├── bin | |
│ ├── node_modules | |
│ ├── papyrusjs | |
│ └── textures | |
├── render.sh | |
├── server.properties | |
├── start.sh | |
└── superops.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bedrock=/home/minecraft/bedrock | |
screen -S minecraft -p bedrock -X stuff 'say §6Starting render...\n' | |
./papyruscs/PapyrusCs --world="$bedrock/backups/latest/worlds/Default/db" --output="/var/www/minecraft-map" --htmlfile="index.html" | |
screen -S minecraft -p bedrock -X stuff 'say §aRender complete!\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Follow symlink to "current" server binary: | |
cd /home/minecraft/bedrock/bin/current/ | |
# Not sure why this is necessary, but it's recommended by Mojang in the guide: | |
LD_LIBRARY_PATH=. | |
# Launch server binary, directing output to stdout and `log.txt`: | |
./bedrock_server | tee log.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This setup is heavily dependent upon
screen
, and named sessions + windows.Setup
Machine
minecraft
, and make them asudoer
for ease-of-access. This is also where you'll want to configure SSH access, and lock things down.screen
session:$ screen -S minecraft
. You can kill this from within the screen instance with[Control + A], [d]
and resume it later from any SSH session by running$ screen -r
. ✌️Server
/home/minecraft/bedrock/bin/
, and create a symlink pointing to it:$ln -s /home/minecraft/bedrock/bin/1.14.32.1 /home/minecraft/bedrock/bin/current
.start.sh
to/home/minecraft/bedrock/start.sh
[Control + A], c
), and name itbedrock
by entering[Control + A], [A]
, and providingbedrock
../start.sh
to boot the server.Backups
backup.sh
to/home/minecraft/bedrock/backup
./home/minecraft/bedrock/backups
directory../backup.sh
to capture a backup. The script will output some in-game messages alerting players that a backup is being made.Maps
Maps are rendered from the most recent backup. This helps keep the state of the world stable during a render.
minecraft
user can write to. We assume/var/www/minecraft-map
, here.papyruscs
to/home/minecraft/bedrock/papyrus
, and copyrender.sh
into/home/minecraft/bedrock
../render.sh
.Miscellany
I'm new to bash scripting. Please comment with improvements or questions! Hoping to use this as a platform for learning. 😸