A server-only backup mod for fabric Minecraft server, which supports both full backup and incremental backup.
GPL-3.0 License
Language | File |
---|---|
English (US) | README.md |
简体中文 | README_zh_CN.md |
Any PR is welcomed. Feel free to add your reasonable features, if you have written test cases for them.
I decided to discontinue my development in this project. There are some major reasons:
To solve these problems, I'm working on a new backup and rollback tool for Minecraft, which is based on rdiff-backup.
As a general incremental backup tool, it tends to be more solid and well-designed. Moreover, it is able to transfer backup files over network. Thus, I believe it is a good start point to reimplement an incremental backup Mod for Minecraft.
However, this tool is still a good choice for any Minecraft server (from 1.14.4 to 1.17.1) who wants to back up its world locally.
A server-only backup mod for fabric Minecraft server, which makes normal .zip
backup of your world, or
self-implemented incremental backup, with slower increasing disk usage.
Supported Minecraft version: 1.14.4, 1.15.2, 1.16.4/1.16.5, 1.17.1, 1.18.1
Fabric API is required!
incremental
folder. (Incremental.kbi
, and it will be saved in backups
folder, which is.zip
resides)/kb restore 1
Only OPs can make backups and restore by default.
However, you can use permission management mods like LuckPerms to configure exactly what permissions normal players can use. Permission nodes of each command are listed below:
Command | Permission Required |
---|---|
/kb | kb.root |
/kb help | kb.help |
/kb list | kb.list |
/kb backup | kb.backup |
/kb incbak | kb.incbak |
/kb restore | kb.restore |
/kb delete | kb.delete |
/kb confirm | kb.confirm |
/kb cancel | kb.cancel |
/kb prev | kb.prev |
Since version 1.8.0
, plugin-wide config file kbackup.json
is added in the server root directory (workdir).
The config file will be generated if not exist. The default is:
{
"incbak_cow": false
}
incbak_cow
: (experimental) Enable filesystem CoW (copy-on-write) for incremental backup.Note: JSON comment is supported.
Due to the nature of JVM: the Java language's running environment, there is no elegant way to restart Minecraft server in a server plugin. In order to auto restart after restoring, an outer system-based script is required, i.e. a batch or a shell script.
KBackup exit JVM with a special code 111
after restoring the level successfully. The startup script just check the
exit code and restart Minecraft server if the code is 111
.
I will give examples for some popular operating systems. To use these scripts, you should replace your start.bat or start.sh script with given code lines.
@echo off
title Keuin's personal Minecraft server
:loop
java -Xms4G -Xmx4G -jar fabric-server-launch.jar nogui
if %errorlevel%==111 goto loop
rem kbackup restore auto restart
pause
#!/bin/sh
STATUS=111
while [ $STATUS -eq 111 ]
do
java -Xms4G -Xmx4G -jar fabric-server-launch.jar nogui
STATUS=$?
done
Currently, KBackup does not support automatic backup by itself. However, If application level scheduled tasks are available to you, such as crontab in Linux and Task Scheduler in Windows, you can use that to trigger backup tasks regularly.
In order to run Minecraft command on your server as a Shell command, you need RCON client
like mcrcon. You can get the binary executable from its homepage and put it into
anywhere like /usr/bin
.
Let's assume you are under Linux, run crontab -e
and append this line to the configuration:
0 */6 * * * mcrcon -P <RCON port> -p <RCON password> "kb backup"
You can specify RCON port and password in server.properties
.
This will cause cron
to run kb backup
for every 6 hours. To make incremental backups, simply replace kb backup
to kb incbak
.
The man page crontab(5) also contains useful information about using cron.
For Windows users, please refer to tutorials available on Google for creating scheduled tasks. Note that mcrcon is also available on Windows.
CoW will save even more disk space when making backups.
This feature requires platform-specific library KBackup-cow. Currently only Linux on x86_64 platform is supported. Please create a GitHub issue if you want other platforms.
This is an experimental feature. Please report if you encountered any error.
Requirements: