Running a dedicated Minecraft server on Azure means I don’t really have to worry about storage. But I do need to worry about unwanted changes to worlds as the server runs for a group of children.
I’ve been testing this with my instance of Ubuntu Server hosted on Azure so it’s all terminal. I’m also going to work with vim as I need to get in the habit of using it rather than nano.
Navigate to the folder with your Minecraft server and create the script file with this command
Press enter and the vim screen will appear. Press i and then type the following text:
now=$(date +"%T_%d_%m") cp world "$now" -r
Press Esc to exit the editing mode. Type :wq and press enter to save the file and quit vim.
Now make the file executable so you can run it (source: Ask Ubuntu)
chmod +x filename.extension
Now you can run the file by entering
and pressing Enter. A folder will appear with the current datetime.
That’s only useful if you want to do this by hand, which isn’t much help when you’re playing.
There’s a Linux command called watch that lets you set a command to run periodically. You’ll need to open a dedicated terminal window for this command as you can’t do this and run the server in the same window.
One of the things that makes Ubuntu Server (well Linux in general) so powerful is the ability to have several terminal windows open at the same time. It’s useful when you need to update the server but can’t wait for that to complete before starting the game.
Bonus tip: If you’re working from Ubuntu Desktop, I recommend installing the Byobu terminal as that includes multiple tabs. On Windows I use PuTTY. To open a new terminal window, right-click the PuTTY icon on the taskbar and then left-click either one of your saved connections or just PuTTY to open the program to select a connection.
With your terminal in the Minecraft folder, type:
watch -n 60 ./backupWorld.sh
The 60 is the number of seconds in between each running of the command. Press Enter and watch will start.
That’s all you’ll see but it is running in the background.
Press Ctrl+C to quit watch. Type ls to see the contents of the folder and you’ll see your backup folders.