8

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.

5
  • 1
    I've voted to close this question because it seems to be asking for a software recommendation, which is off-topic. Mar 4, 2013 at 5:53
  • 1
    @ktash Is there a way for me to reword it in a way so that it is on topic?
    – user28379
    Mar 4, 2013 at 20:44
  • 1
    This question is being discussed at Arqade Meta: meta.gaming.stackexchange.com/questions/6962/… Mar 6, 2013 at 14:04
  • I'm just confused as to why it was not closed when I first asked it.
    – user28379
    Mar 7, 2013 at 1:11
  • 2
    @jeffreylin_ yeah I feel your pain .. some moderators just quickly vote to close without even asking for more information regarding your question ... Oh and also a bombardment of downvotes .. haha ..
    – Render
    Mar 9, 2013 at 20:57

2 Answers 2

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

9

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.

7
  • Do you have a version of this for Windows?
    – user28379
    Mar 2, 2013 at 21:47
  • I'm afraid not :(
    – pwaller
    Mar 3, 2013 at 22:42
  • Darn. I need this for Windows though.
    – user28379
    Mar 3, 2013 at 22:43
  • Hi! I appreciate I'm (very) late to this party, but just wanted to say thanks for this. It's really helpful. One question: I notice you include "stuff" before the minecraft commands. Is this just some form of padding (it's not a terminal command on my machine). I find it very odd that the commands don't seem to work without "stuff" even though it isn't technically valid. Thanks.
    – Josh
    Jul 10, 2017 at 17:11
  • 1
    You're going to pinch yourself, as I just pinched myself reading your comment. stuff is the command. As in "to stuff some things into the terminal".
    – pwaller
    Jul 11, 2017 at 18:11

You must log in to answer this question.