Minecraft Backup
Automated, Git-versioned backups for Minecraft servers in Docker, on the Java server or Horizon (Rust)
Overview
Minecraft Backup wraps a Minecraft server with a custom entrypoint that treats the world folder as a Git repository. It ships two images: one built on the official itzg/minecraft-server Java image, and one running Horizon, the community rewrite of Minecraft 26.3 in Rust. The world is restored from GitHub when the container starts, committed and pushed at a fixed interval while people play, and backed up one last time after the server stops cleanly, so a world can always be recovered, moved to another machine or rolled back to an earlier commit.
- Periodic backups: a Git commit every
PERIODIC_INTERVALminutes, created only when something changed. - Consistent snapshots: automatic saving is paused (
save-off/save-all flush) while files are staged. - Graceful shutdown: the server stops first, then the final backup is committed and pushed.
- Safe credentials: the GitHub token stays in memory, never in the remote URL, the repository config or the logs.
- Any Git remote: GitHub by default, or GitLab, Gitea or a bare repository through
GIT_REMOTE_URL. - Java or Horizon (Rust): both servers use the vanilla world format, so the same backup repository can move from one to the other.
- Compatible with the official image: every
itzg/minecraft-servervariable still works on the Java image.
Quick start
git clone https://github.com/danieltorquatof/minecraft-backup.git
cd minecraft-backup
cp .env.example .env # set GITHUB_USER, GITHUB_TOKEN and REPO_NAME
docker compose up -d --buildFor Horizon, prepare the Minecraft 26.3 game files from your own copy of the game with the Horizon launcher, then:
cp .env.horizon.example .env # backup variables + HORIZON_EULA and HORIZON_RESOURCES_DIR
docker compose -f docker-compose.horizon.yml up -d --buildThe README covers the token permissions, every variable, the Horizon setup and how to restore an older backup.
Updates
| Date | Update |
|---|---|
| 2026-11-05 | Horizon (Rust) support (PR #2, PR #3): a second image runs a pinned, checksum-verified Horizon release with the same Git backups. Console commands go through Horizon’s local control API instead of RCON, the world name and game files are set up on start, and stopping the game from inside (/stop) now ends the container with a final backup, as on the Java server. CI builds both images and smoke-tests Horizon. |
| 2026-10-22 | Reliability and security release (PR #1): backup commits no longer fail silently, graceful shutdown before the final backup, token removed from remote URLs and logs, consistent snapshots with backup locking, safer handling of empty or diverged remotes, RCON no longer published, Java 25 base image and CI (ShellCheck, Hadolint, compose validation, image build). |
| 2025-12-04 | Initial release: periodic Git backups to GitHub, restore on startup and backup on shutdown. |