Minecraft Java Edition and Bedrock Dedicated Server (BDS for short) systemd units, bash scripts, and chat bots for backups, automatic updates, installation, and shutdown warnings
MCBEbackup.sh also works with Docker
@@@ Compatible with Ubuntu @@@
Ubuntu on Windows 10 does not support systemd (Try my Ubuntu Server 18.04 Setup). You can run MCgetJAR.sh, MCBEgetZIP.sh, and MCBEupdate.sh without enabling the systemd units, but no others. No automatic update scripts or chat bots for Java Edition.
How to send input to and read output from the server console:
# Send input to server console
sudo su mc -s /bin/bash -c "echo $input > /run/$service"
# Read output from server console
systemctl status $service
# Bedrock Dedicated Server example
sudo su mc -s /bin/bash -c "echo save query > /run/mcbe@MCBE"
systemctl status mcbe@MCBEHow to add everyone to Bedrock Dedicated Server whitelist:
for x in steve alex herobrine; do sudo su mc -s /bin/bash -c "echo whitelist add $x > /run/mcbe@MCBE"; doneHow to control systemd services:
# Backup Minecraft Bedrock Edition server
sudo systemctl start mcbe-backup@MCBE
# Stop Minecraft Bedrock Edition server
sudo systemctl stop mcbe@MCBEBackups are in ~mc by default. systemctl status mc-backup@MC mcbe-backup@MCBE says the last backup's location. Outdated bedrock-server ZIPs in ~mc will be removed by MCBEgetZIP.sh. MCBEupdate.sh only keeps packs, worlds, JSON files, and PROPERTIES files. Other files will be removed.
PS4 and Xbox One can only connect on LAN, Nintendo Switch cannot connect at all. Try jhead/phantom to work around this on PS4 and Xbox One. Try ProfessorValko's Bedrock Dedicated Server Tutorial.
Open Terminal:
sudo apt install curl git socat wget zip
git clone https://github.com/TapeWerm/MCscripts.git
cd MCscripts
sudo adduser --home /opt/MC --system mc
# I recommend replacing the 1st argument to ln with an external drive to dump backups on
# Example: sudo ln -s $ext_drive ~mc/backup_dir
sudo ln -s ~mc ~mc/backup_dirCopy and paste this block:
sudo cp *.sh ~mc/
sudo chown -h mc:nogroup ~mc/*
sudo cp systemd/* /etc/systemd/system/Change shutdown warning to 20 seconds if you want:
sudo sed -i 's/MCstop.sh/MCstop.sh -s 20/' /etc/systemd/system/[email protected] /etc/systemd/system/[email protected]Stop the Minecraft server.
sudo mkdir ~mc/java
# Move server directory (Replace "$server_dir" with Minecraft server directory)
sudo mv "$server_dir" ~mc/java/MC
# Open server.jar with no GUI and 1024-2048 MB of RAM
echo java -Xms1024M -Xmx2048M -jar server.jar nogui | sudo tee ~mc/java/MC/start.batCopy and paste this block:
sudo chmod +x ~mc/java/MC/start.bat
sudo chown -R mc:nogroup ~mc/java
sudo systemctl enable [email protected] [email protected] [email protected] --nowIf you want to automatically remove backups more than 2-weeks-old to save storage:
sudo systemctl enable [email protected] --nowStop the Minecraft server.
sudo mkdir ~mc/bedrock
# Do one of the following:
# Move server directory (Replace "$server_dir" with Minecraft server directory)
sudo mv "$server_dir" ~mc/bedrock/MCBE
# OR
# Make new server directory
sudo su mc -s /bin/bash -c '~/MCBEgetZIP.sh'
sudo ~mc/MCBEautoUpdate.sh ~mc/bedrock/MCBECopy and paste this block:
sudo chown -R mc:nogroup ~mc/bedrock
sudo systemctl enable [email protected] [email protected] [email protected] mcbe-getzip.timer [email protected] --nowIf you want to automatically remove backups more than 2-weeks-old to save storage:
sudo systemctl enable [email protected] --nowIf you want to post server logs to IRC:
sudo su mc -s /bin/bash
mkdir -p ~/.MCBE_BotEnter nano ~/.MCBE_Bot/MCBE_BotJoin.txt, fill this in, and write out (^G = Ctrl-G):
NICK $nick
JOIN #chan $key
PRIVMSG #chan :$msg
...
irc.domain.tld:$port
If NICK line is missing it defaults to MCBE_Bot. PRIVMSG lines are optional and can be used before JOIN to identify with NickServ.
Copy and paste this block:
exit
sudo systemctl enable [email protected] [email protected] --nowIf you want to post server logs to webhooks (Discord and Rocket Chat):
sudo su mc -s /bin/bash
mkdir -p ~/.MCBE_BotEnter nano ~/.MCBE_Bot/MCBE_BotWebhook.txt, fill this in, and write out (^G = Ctrl-G):
$url
$url
...
Copy and paste this block:
exit
sudo systemctl enable [email protected] --nowDisable the services you use and remove their files:
cd MCscripts
git pull origin master
sudo ./DisableServices.shUpdate the services:
sudo apt install curl git socat wget zip
# I recommend replacing the 1st argument to ln with an external drive to dump backups on
# Example: sudo ln -s $ext_drive ~mc/backup_dir
if [ ! -d ~mc/backup_dir ]; then sudo ln -s ~mc ~mc/backup_dir; fi
sudo ./MoveServers.shCopy and paste this block:
sudo cp *.sh ~mc/
sudo chown -h mc:nogroup ~mc/*
sudo cp systemd/* /etc/systemd/system/Change shutdown warning to 20 seconds if you want:
sudo sed -i 's/MCstop.sh/MCstop.sh -s 20/' /etc/systemd/system/[email protected] /etc/systemd/system/[email protected]Reenable the services you use:
sudo systemctl enable "$services" --now