How do I make an automatic server backup in Minecraft?

Solution 1:

See here for a list of Server managers, which should help you with more than just backups. http://www.minecraftwiki.net/wiki/Programs_and_editors/Server_wrappers

Solution 2:

On Linux, I came up with a rather basic solution which you can find here: https://github.com/pwaller/waitsilence

The idea is to use inotifywait | waitsilence to determine when minecraft has finished writing its backup out. That allows you to avoid corruption.

If you run your minecraft session inside a named screen (e.g, screen -S minecraft), then you can send text into minecraft's input with screen -r -S minecraft -X stuff $'\nsave-all\nsave-off\n'. The -r flag prevents the screen writing save-all, save-off into the screen if it is currently attached.

inotifywait then writes what file modifications are seen, and I wrote waitsilence (above) to wait until nothing has been written for a few seconds.

This can all be put into a backup.sh script which is then run via cron.