Automated Minecraft Server backups

Note: this post was migrated from my old Tumblr-backed blog

Update (2011-08-30)

mcwrapper 1.4 has been released. it includes a slew of new features including backups. See other posts for more info or look at the github page:

https://github.com/spikegrobstein/mcwrapper

I’ve been running a Minecraft server off my MacMini for the past month or so and, in doing as much work as I have and being the vigilant SysAdmin that I am, it was really starting to irk me that there was no way to do proper automated backups of the Minecraft server world data.

The solution for this was that I needed to wrap minecraft_server.jar in another script that could somehow take commands as input and pass them off to the minecraft server so I wouldn’t need to run the daemon in the foreground. I wound up doing just that.

mcwrapper is the answer: https://github.com/spikegrobstein/mcwrapper

It’s got the ability to start and stop the server, which are the beginnings to getting launchd (OSX) and sysV init scripts (Linux) to enable you to treat minecraft_server.jar as a standard daemon.

Because I’m using a FIFO to communicate with the Minecraft process, you can also pipe data to the FIFO to execute arbitrary commands and script your cheats or stop Minecraft from writing to the world files while a backup process is run and start it back up when completed, thereby doing a full, automated backup without stopping the server.

See the README file for a quickstart and other details.

The software is only an alpha release right now, since I only spent about 2 hours on it already, but I believe it should be usable. As of this writing, it’s possible to start multiple instances of the server, but mcwrapper does check to make sure the server is running before issuing any commands.