How do I make an automatic server backup in Minecraft?
There is no built-in implementation in a Vanilla Minecraft server to force a save every X minutes, then back up the files into a folder. I know how to do log rotations and I can also do a normal backup using Window's XCOPY or ROBOCOPY, but have no idea how to do it when the server is running to prevent possible data corruption.
How can I perform an automatic backup that ensures a consistent state of the game data?
The server is running on Windows.
52 Answers
See here for a list of Server managers, which should help you with more than just backups.
On Linux, I came up with a rather basic solution which you can find here:
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.