Managing a Minecraft Server: Advanced Tips
Back in November, we showed you how to go about configuring a Minecraft server on a dedicated server or cloud VPS. For those who missed it, you can find it here and get your own Minecraft server experience started. This time, we’ll look at more details of how it’s running and offer a few advanced tips and tricks on configuring and managing the server.
First, we’ll cover some aspects of the Minecraft command line interface. Yes, Minecraft has its own command line, similar to working in BASH. The startup script we used for launching Minecraft left us with the Minecraft server running in a screen session owned by the Minecraft user on the server. Screen is a tool designed that allows you to run multiple simultaneous applications in the background, independent of your current user session on the server. A screen session allows the user to leave or rejoin it at a later date.
Command Line Interface
To access the running screen session your Minecraft server is running in, you’ll need a few things. We need to log into the server as a user with sudo permissions or the root user. If you can’t log in then you’ll need to know the password that the Minecraft user was created with. Once logged in you can change to the Minecraft user account using the following command:
sudo su minecraft
If you don’t have sudo/root access then you’ll need to user the following command where you will be prompted to enter the minecraft user’s password:
Once you are in the Minecraft user’s account, you can then connect to the Minecraft server itself using the following command:
screen -r minecraft_server
You should see a number of information lines on your screen from the Minecraft server. You can type commands directly to it, similar to how you would when playing as a user with op access in the game. Note that when entering commands directly to the server you don’t need to include the preceding / that you would use when in the game itself. For those unfamiliar with commands, a full list is available on the official Minecraft Wiki found here.
Once you are finished using the Minecraft server’s interface, you’ll need to disconnect without closing it. This is done with the following key combination, first press Ctrl-a, and then press d to detach from the screen session. This will leave your server running in the background after which you can then disconnect from the server with everything running as normal.
Backing Up Your Minecraft World
The keen eyed among you will note that we set up a backup directory in the startup script for the server, but didn’t actually touch making a backup itself. This can be done using the following command when logged in as a user with sudo access or the root user:
sudo /etc/init.d/minecraft backup
Note that bu default takes a one-off backup of your world and stores it on the same server as your Minecraft installation. This is fine as a basic protection against a clumsy accident in the Minecraft world itself (say someone accidentally drops some lava and burns a district of the server down). But it is not so helpful in the case of a server filesystem problem or disk failure. It also relies on you manually taking the backup.
So it’s worth at least adding a cron task to take regular backups of the Minecraft world. To do this you can add it to the cron table with the following commands:
sudo nano /etc/crontab
Now add the following line to the bottom of the file:
0 * * * * root /etc/init.d/minecraft backup
Then save and exit the file. This addition means that the backup function will be run on the hour, every hour — meaning the most out of date that any backup will be within the hour. If you have a remote server you can copy your backup to or a separate drive in your existing server, it could be an idea to configure a script to copy this backup to the other location.
There you have it, hopefully these tips have been helpful and will aid you in managing your Minecraft server. Happy crafting.
Originally published at blog.100tb.com.