Minecraft Backups to Amazon S3

May 20, 2018
Category: Mini-Projects

Tools: BASH, Amazon Web Services (AWS), VirtualBox, McMyAdmin

I happen to be playing around with AWS and found out that you could host a Minecraft server on EC2. When I played Minecraft back in 2012, I always had to spin up the server and after each session I backed up world by copying them to the same folder. Now with Amazon S3, backups can be cheap and automated. So I made this installer script to help me build an instance with automated backups. One of the challenging things when building this script was testing to make sure it works. I had a VirtualBox snapshot I could restore to, but this can only do so much if I don’t have access to dry-running the backups.

This was my first time using AWS S3 and it was challenging to make sure that my code would trigger at the exact time each day (or week). Aside from the backups, there’s a number of other features I figured out and automated:

  • Setup the correct timezone for your server, this makes backup schedule run in times you’re expecting them to. Especially if those 4 am backups happen during a peak server time due to incorrect timezones
  • Lifecycles for backup objects help save backup costs by deprecating backups to lower availability storage classes on S3. I have mine setup for STANDARD_IA after 30 days and GLACIER after 90 days. I figure someday I could probably do some time-lapse or visualization with all that data hoarding. Leaving the regular backups on STANDARD lets me restore immediately from the latest backups when I need it.
  • McMyAdmin’s configurations need to be setup every time. This is rather annoying, so I also setup an automated weekly backup for the configuration files too in case I forget the settings.

Check out the script on my GitHub: Source (GitHub)