A robust, automated Minecraft backup system powered by Docker and GitHub.
This repository — danieltorquatof/minecraft-backup — provides a fully automated backup workflow for Minecraft Java Edition servers running inside Docker. It integrates Git versioning, GitHub remote storage, periodic world saves, structured logging, and graceful shutdown procedures.
The solution is built on top of the official itzg/minecraft-server image (tested with java21 / LATEST) and enhances it with a custom entrypoint that triggers backup routines at startup, shutdown, and at periodic intervals.
-
Automated World Backups Saves your Minecraft world at regular intervals using Git commits.
-
GitHub Integrated Storage Pushes backups to a private or public GitHub repository.
-
Graceful Shutdown Protection Ensures a complete world save whenever the container stops.
-
Fully Compatible with Official Image Environment Variables You can configure the server using any variables supported by the original Docker image.
-
Extensible & Maintainable Scripts are modular and can be easily customised.
.
├── docker-compose.yml
├── Dockerfile
├── entrypoint.sh
├── .env.example
├── .gitignore
├── README.md
├── scripts
│ ├── autosave.sh
│ ├── init.sh
│ ├── shutdown.sh
├── utils
│ ├── log.sh
│ ├── saveWorld.shgit clone https://github.com/danieltorquatof/MinecraftBackup_Docker.git
cd MinecraftBackup_DockerUse the provided .env.example:
cp .env.example .envThen edit .env and fill in all required environment variables (see next section).
docker compose up -d --buildThe Minecraft server will start, periodic backups will be scheduled, and logs will be written to ./logs.
This token is used for pushing commits from inside the container to your GitHub repository.
Follow the official GitHub documentation: 🔗 Managing your personal access tokens
The scopes typically required are:
repo(full repository access)
Add the token to your .env:
GITHUB_TOKEN=your_token_hereThis repository will store your automatic world backups.
Official Guide: 🔗 Creating a new repository
Then put the repository name only (not the full URL) in your .env:
REPO_NAME=MyMinecraftWorldThese must also be configured:
| Variable | Description |
|---|---|
GITHUB_USER |
Your GitHub username (owner of the token). |
SEED |
(Optional) Minecraft world seed. Can be commented out. |
RCON_PASSWORD |
Password for remote console access. Preferably random. |
PERIODIC_INTERVAL |
Automatic backup interval in minutes (default: 15). |
You can generate a secure RCON_PASSWORD here:
Password Generator
This project is based on the official image:
🔗 Minecraft Server on Docker (Java Edition) [latest]
All official environment variables of the itzg/minecraft-server image remain fully functional and compatible.
Example customisations such as:
EULA=TRUE
TYPE=VANILLA
VERSION=LATEST
MEMORY=4G
ENABLE_RCON=true…are available as usual through docker-compose.yml or your .env.
This project was built and tested against:
- Base image:
itzg/minecraft-server:java21 - Minecraft version:
LATESTat the time of development
Future versions should remain compatible, but behaviour may vary.
- The container initialises the backup repository.
- If the repo exists, it pulls updates.
- If empty or missing, it prepares everything automatically.
- Backups occur every N minutes (
PERIODIC_INTERVAL). - World is saved → committed → pushed to GitHub.
- A final world save is triggered.
- Final commit is pushed.
- Logs are stored for auditing.
| Directory | Purpose |
|---|---|
data/ |
Global Minecraft server data + backup Git repository. |
logs/ |
Logs for entrypoint, autosave, shutdown and init scripts. |
Contributions, issues, and pull requests are welcome. Before submitting PRs, ensure your changes follow good Bash practices and maintain compatibility with the official server image.
This project is available under the MIT licence.