Matik.Org

Minecraft Server on Raspberry Pi

There already exist instructions on how to install minecraft on a raspberry pi already. I mostly followed this guide: https://linuxize.com/post/how-to-install-minecraft-server-on-raspberry-pi/

However, I would like to document exactly what I did, so I can properly replicate it.

I have had bad luck with raspberries performing a unscheduled disassemblies – it looks like this is due to running out of space on upgrades, leaving the system without sshd and other nice to have things. Fixing these situations is pretty tricky since you never know if you got the system back into the proper state. So being able to create a new image from scratch without much fuss is the goal.

Hence I’ll document here

  1. How to setup an image from scratch,
  2. How to recover from a lost raspberry.
  3. How to make backups, including offline backups

New Install

Install minecraft / install from existing server

Again, a from-scratch install is described at https://linuxize.com/post/how-to-install-minecraft-server-on-raspberry-pi/. Since I still have a pi image with a bad OS (upgrade went bad), I will just copy from previous incarnation for now.

Backup

Backup instructions: https://gist.github.com/kmtu/6326127, https://www.google.com/search?q=minecraft+server+backup+%22mcrcon%22

This script makes a local backup, but it also can write to a remote server. Since I am worrying about the SD card with the backups going belly-up, I also make a copy of the created backup file on a secondary server (a pihole RPi that’s moinitored by prometheus).

% brew install e2fsprogs
% sudo dd if=/dev/rdisk2 of=/Users/matik/Downloads/picraft.large.img bs=1m
% sudo pishrink /Users/matik/Downloads/picraft.large.img
% gzip /Users/matik/Downloads/picraft.large.img

Epilogue

I can now create a replacement image in a short time. The instructions above could help you too. I would however infinitely prefer an automated solution, like the ability to make snapshots on a running system. Amazon lightsail allows me to do this (OS independently, I tested linux and freebsd). Even a solution to create a copy of the image that requires a reboot, mounting root read-only and streaming it to a NAS would be great. Maybe in the future. If you have feedback, please peruse the comments.

Written on July 2, 2020