I am working on a server admin script, and am trying to automate backups of my world directories on regular intervals. I know the commands save-off
and save-all
are what I should be doing to flush the current state to disk before creating my backup. However, I am getting some unexpected behavior I believe is a bug.
My backup-process is basically this:
issue
save-all
command, wait for "Saved the world" to be output by serverissue
save-off
command, wait for "Turned off world auto-saving" to be output by serverCreate a tar.gz archive via
tar czf "/path/to/backup.tar.gz" .
(with the server dir as the cwd)issue
save-on
command, wait for "Turned on world auto-saving" to be output by server
Currently, I have to add a 5 second delay between steps 2 and 3 because otherwise, my tar
command will always fail because files within the directory are modified during the attempt at creating the tar file.
Something in the server output is misleading, my suspicion is either save-all
or save-off
is reporting completion incorrectly, or perhaps I am not approaching this backup process correctly.
Comments 7
Yeah, that seems to work better and doesn't need the full 5 seconds I was needing before. Still requires a delay unfortunately, which is what I'm hoping can be avoided.
Yeah, understandable given it runs multi-threaded. All I'm hoping is that the devs will delay printing "Save Complete" until saving is actually complete, otherwise I can never be entirely sure when it is safe to back-up... without resorting to ridiculous loops/polling. 😛
Resolving then. For "save complete" issue see MC-2527.
I recently went through the same process as you, but i did something slightly differently.
1. I execute save-off
2. I execute save-all
3. Wait 2 seconds
4. I create the backup
5. I execute save-on
Does this help?