Search This Blog

Wednesday, May 1, 2024

PowerShell: Managing your Minecraft Server

My Minecraft server is running on a separate computer, simply to offset the resource requirements to a separate device.

When managing this server I use RDP to access the GUI and while on the management server I have simplified the management through some PowerShell scripts.

Here are the general outline of the scripts I have connected at this stage.

Currently in development:

Minecraft server start, a script that checks if the .exe is existing and if the process is running. If .exe exists but the process is not running, it starts the process.

Minecraft server stop, basically the reverse. It checks if the process is running, and if so, it issues a stop command to the server.

Minecraft server upgrade, this script is more advanced. It brings home the latest version (at this point hardcoded) and then performs a replacement action, making sure the properties and the world is not lost. Finally it inserts the backed up files again. Lastly it performs cleanup.

Scripts that are tried and tested:

Minecraft diagnostics, a script that performs a general health check. Are all files presents? Is the process running? What is the size of the Minecraft folder?

Minecraft backup, stops the server process, performs copies of the properties and the world, places them on a separate drive and then starts the process again. This is a vital component, because you need a regular backup and in theory you could add this to a schedule and include cleanup functionality.


Future script ideas:

Another project I am considering is a restore script, that combines functions from the backup, diagnostic and the upgrade, basically a script that checks for damage to the folder and perhaps compares with a baseline. Then perform basic replacement and cleanup actions to restore the folder to the best of its ability.

You can also use compare-object to check the contents of the properties for example, to check for corruption.

Last but not least, perhaps there is a way to perform a hashing fingerprint of the world.

No comments:

Post a Comment