This guide is intended to suplement the official GCE documentation on setting up a Minecraft server. That guide is a great start but there are a few suboptimal things recommended in that document and a few things missing that most people will want to do.

Boot disk

That guide recommends an SSD boot disk. This isn't needed; Minecraft doesn't run from the boot disk.

/etc/fstab

The guide never has you place the Minecraft volume in the /etc/fstab so that it is automatically mounted again after boot. To do that, just add the disk to the /etc/fstab file on a new line:

$ cat /etc/fstab 
UUID=3b550ed9-dcc3-4874-b387-a64b31d29eec / ext4 defaults 1 1
UUID=[your UUID here] /home/minecraft ext4 discard,defaults 0 2

You can obtain the UUID of the disk by looking in /dev/disk/by-uuid. It's the UUID that isn't already in your /etc/fstab.

systemd service

The guide offers bad advice on how to configure Minecraft to start automatically at boot and shutdown in the section at the end titled Automate start up and shutdown procedures. Completely ignore that section. Implementing proper systemd units handles all of this automatically.

First, install tmux. We're going to use that to host the Minecraft server console inside of the systemd service:

sudo apt-get install tmux

Create a new file as root /etc/systemd/system/minecraft.service:

[Unit]
Description=Minecraft server

[Service]
WorkingDirectory=/home/minecraft
User=minecraft
Type=forking
ExecStart=/usr/bin/tmux new-session -s minecraft -d '/usr/bin/java -Xmx4096M -jar minecraft-[YOUR VERSION].jar'
ExecStop=/usr/bin/tmux send-keys -t minecraft:0.0 'say SERVER SHUTTING DOWN. Saving world...' C-m 'save-all' C-m 'stop' C-m
ExecStop=/bin/sleep 2

[Install]
WantedBy=multi-user.target

Then, start it for the first time:

sudo systemctl daemon-reload
sudo systemctl start minecraft

You can see if the server started by inspecting the status:

sudo systemctl status minecraft

If you don't see anything, look at the logs/latest.log in /home/minecraft.

If you want to attach the console to confirm that everything looks right, you can do this:

sudo -i -u minecraft tmux attach

Press CTRL-B D to detatch from the console if it looks like it's working.

If that worked, enable it at boot time:

sudo systemctl enable minecraft

systemd will automatically shutdown your server gracefully when your instance is shutdown gracefully. You can try it with systemd stop minecraft.

Backup script

The guide has a rudamentary backup script that uses the old /etc/crontab. We can do much better.

First, make a new systemd unit in /etc/systemd/system/minecraft-backup.service:

[Unit]
Description=Minecraft server backup

[Service]
WorkingDirectory=/home/minecraft
User=minecraft
Type=oneshot
TimeoutStartSec=600
ExecStart=/home/minecraft/backup.sh

Then, create the backup.sh file:

#!/bin/bash

set -e

function cleanup {
    /usr/bin/tmux send-keys -t minecraft:0.0 'save-on' C-m 'say Finished backup.' C-m 'save-all' C-m
}
trap cleanup EXIT

/usr/bin/tmux send-keys -t minecraft:0.0 'say Starting backup.' C-m 'save-off' C-m
/bin/sleep 5
NOW=$(date +%Y%m%d%H%M)
/bin/tar -czf backups/yourworld-${NOW}.tar.gz yourworld
/usr/bin/gsutil cp backups/yourworld-${NOW}.tar.gz gs://name-of-your-backup-bucket/
/usr/bin/find backups/ -mtime +4 -exec rm {} \;

This script will keep 4 days of rolling backups locally while still uploading to the Google Storage bucket suggested by the guide. Create that directory as the minecraft user and chmod the script to +x:

mkdir backups
chmod +x backup.sh

Finally, add a systemd timer in /etc/systemd/system/minecraft-backup.timer and enable it:

[Unit]
Description=Run minecraft-backup.service every 4 hours

[Timer]
OnCalendar=*-*-* 00/4:00:00

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable minecraft-backup.timer

You can test the backup process manually with systemctl start minecraft-backup.

Don't forget to do the Automatically remove old backups step in the offical guide so that your GS bucket doesn't fill up forever.

Shutdown manually

You can shutdown from systemd:

sudo systemctl stop minecraft

Or, you can attach to the running server, make an announcement to your players with say ... and then type stop:

sudo -i -u minecraft tmux attach

Bonus: serving texture/resource packs

If you have a texture pack that you want to serve to your players, you can add that to a new Cloud Storage bucket (not the same as your backups), make that bucket public, and then copy the theme pack URL into your server.properties file. The public URL is available from the Cloud Storage browse UI: it's a small link icon on the file listing next to the Public status once the ZIP file has been made publicly accessible. Don't forget to compute the SHA1 and also add that to your server properties.