Saving the state of my Torque created Minecraft server

Saving the state of my Torque created Minecraft server

Hi Y’all! 

Last time I wrote about using Torque, an Environment as a Service tool, to create a Minecraft server. Torque is great for saving costs, as it can create an environment for a fixed duration: 

What happens when the environment is shut down? All the resources created in the cloud account linked to Torque are shut down and deleted. For my Minecraft server, that means that the world and files created on it will be lost. To avoid this scenario, Torque lets you to save to seed our environment the next time we spin one up.  

So how do we do this? It’s easy and requires just a few steps: 

  • Zip and save Minecraft server state files on the server 
  • Upload the zip as an artifact to your favorite artifact server 
  • Start next Minecraft environment as normal 
  • Download latest Minecraft server state artifact 
  • Unzip and copy to server install 

Creating Minecraft Server State Files 

When users connect to your Minecraft server, they will change the Minecraft world. This change is stored in files located within the install directory; in this case, it is located within /opt/minecraft on vm1 within the environment. 

These files need to be zipped up. To do that, run Minecraft server console command /save-all. Because the application yaml runs the server in a screen session, we’ll need to connect to the server via SSH, then reattach to the screen session the Minecraft server jar process is running within to issue the minecraft server specific  commands.  

To do this, first enable ssh access to your server. In Torque, go to your sandbox, click the Troubleshooting tab, turn on bastion, then click the ssh button. This will launch a new browser window that will be your ssh session: 

Once ssh session is open, switch to root, then connect to your screen session: 

sudo su – 

screen -r myserver 


Next, press Ctrl+a, then ‘d’ to disconnect from the screen session. This is important as it allows us to leave the server process running even after we disconnect. 

You’ll need to zip up the entire install directory, like so: 

cd /opt 

tar cvzf minecraft/ 

The file is our Minecraft backup; I curled it up to my S3 bucket that contains other artifacts used by Torque. 

Debugging / Troubleshooting our Minecraft Sandbox 

Now that I’ve created the, what do I do with it? How will I get that to “seed” my next created environment?  

While I’ll want to do this automatically, I’ll show you how to do it manually first, because it will show you what you will want to automate as well has how to debug your environment.  

Debugging your sandbox is a common enough task on your way to learning how to automate specific processes (I’m sure not all of us will be creating a Minecraft Server sandbox for our kids with Torque ).  

To access specific parts of your sandbox, within your blueprint.yaml, enter the following YAML element with the following members (described here and below): 

direct_access: on
bastion_availability: enabled-on 

This will provide you with access to the various VMs within your sandbox. Since Torque is an application-centric/application aware IaaS, you must also state within the application.yaml how that direct access may be achieved. Since I have a Linux-based VM, I use ssh for the direct access shown below and in my application yaml: 

allow_direct_access: true
connection_protocol: SSH 

Once you’ve made those add/changes to your blueprint, launch the sandbox and click the Troubleshooting tab followed by the ssh button (under Direct Connect). 

This will bring up a window that shows you how to connect to the server via ssh, including the ability to download the necessary ssh key: 

With the above information, I was able to manually pull the artifact off the server and later restore the world in a newly created sandbox. Here’s how that went … 

Retrieving the artifact 

To refresh your memory, I create a zip of the /opt/minecraft folder and saved in opt, called 

Now that we have ssh key and server address, use scp to pull the artifact down to your local server. Here’s the command I used: 

scp -i debugging-keypair-ru21axvp4g13c1.pem*.zip . 

Later when I create another sandbox, I’ll take that same artifact and scp it up to the new Sandbox VM.  

Restoring your Minecraft World 

Now that I have my artifact safely off the Sandbox, I can let the sandbox timer expire (or if I’m done with the Sandbox, I can directly end it in Torque). Torque will take care of all the shutdown and reclaiming of resources, avoiding excess charges from your cloud provider. 

Let’s say you get some free time on the weekend, and you want to continue building your Minecraft world (and in my case, get some bonding time with my son). You’ll start up a new Minecraft Sandbox as we did in part 1. Here’s a refresher: 

Open Torque, and click “New Sandbox” 

In Part 1, we showed how to connect your Torque instance to your blueprint repo. Those blueprints are selectablehere we’ll select “minecraftserver. 

You’ll be asked to enter input parameters defined in your blueprint.yaml, the server properties don’t really matter because we are going to restore our backup world right over this.  

After you input all your desired parameter values, click “launch sandbox” and Torque will email you when the sandbox is ready. It will take just a few minutes. 

Use the Troubleshooting tab to access the information on connecting via ssh. You’ll also need to download the ssh key to scp up the backup, which you can accomplish like so: 

scp -i debugging-keypair-tk56h150fw13c1.pem 

Once the zip has been copied to the /tmp folder, ssh into the server by copying the command from the Troubleshooting tab —  like this: 

ssh -i debugging-keypair-tk56h150fw13c1.pem 

sudo su –  

cd /opt 

Shut down the existing minecraft world 

screen -r 


This will bounce you out of the screen session since the java process will end, then enter: 

rm -rf minecraft/ 

tar xvzf /tmp/ 

screen -dmS myserver /usr/bin/java -jar /opt/minecraft/server.jar –nogui 

Next, exit the server. Your Minecraft server will start and you can connect and pickup where you last left off. 


Thanks for keeping up! We learned the troubleshooting and access capabilities of Torque with a real life task of backing up and restoring a Minecraft Server. 

One more thought: A Note on Seeds 

After I wrote Part 1 and had my key stakeholder (my son) review, he asked that I add a parameter called SEED, which is used to “seed” your minecraft world with certain structures and resources. Seed values can be found here. I take the value given and insert it into the Minecraft file shown below within the application.yaml’s startup script. 

echo “==> Updating the seed value is $SEED”
sed -i ‘s/level-seed=/level-seed=$SEED/’ /opt/minecraft/