World Backup
只需按下按键或输入命令,即可简单、可靠地备份世界——
是否曾遭遇过因失控的模组、断电或 WorldEdit 操作失误而导致的世界损坏?World Backup 允许你通过一条命令瞬间创建整个世界文件夹的压缩 ZIP 备份。备份在后台异步运行,确保服务器不会卡顿,而自动轮换机制则防止磁盘空间被占满。
✨ 功能特性
- 即时备份 — 使用
/backup <name> 命令即可创建完整的 .zip 世界备份
- 非阻塞式 — 备份在独立线程中运行;你的服务器保持响应状态
- 自动轮换 — 根据可配置的上限自动清理旧备份
- 可配置 — 可通过命令或 JSON 配置文件设置备份数量上限
- 默认安全 — 名称验证可防止路径遍历攻击
- 兼容冲突文件 — 先将世界复制到临时目录,再从干净的副本进行压缩。由其他模组(如 Sable)锁定的文件会自动重试,并采用递增退避策略
- 全服广播 — 所有玩家都能看到备份进度和完成消息
? 命令
| 命令 |
描述 |
/backup <name> |
使用给定名称创建一个带时间戳的 zip 备份 |
/backuplimit <number> |
设置保留的最大备份数量(1–1000) |
示例:
/backup before-portal → before-portal_2025-06-03_21-30-00.zip
/backup vanilla-test → vanilla-test_2025-06-03_21-31-15.zip
/backuplimit 25 → 将轮换限制设置为 25 个备份
默认情况下,所有玩家都可以使用这些命令——无需操作员权限。
⚙️ 配置
备份上限存储在服务器目录内的 backup/backup_config.json 文件中。该文件会在首次使用时自动创建,也可以直接编辑:
{
"backupLimit": 10
}
也可以通过游戏内命令 /backuplimit <number> 更改上限。
? 备份存储位置
备份保存在服务器目录下的 backup/ 文件夹中(与世界文件夹同级)。每个备份都是一个压缩的 .zip 文件,命名格式如下:
<name>_<YYYY-MM-DD_HH-mm-ss>.zip
? 兼容性
World Backup 旨在与其他模组和平共存:
- Sable — 完全兼容。世界文件会在压缩前复制到临时目录,因此 Sable 的文件锁定不会造成干扰。最多重试 5 次,并采用递增退避策略
- Ice and Fire、Dread Land 及其他维度模组 — 所有子层级和自定义维度都会被备份
- 任何文件锁定模组 — “先复制后处理”的策略结合重试逻辑,能够处理其他模组锁定的文件,而不会跳过数据
- 任何世界类型 — 适用于原版、模组加载版及自定义世界格式
? 技术细节
- 先复制策略 — 世界文件夹使用
Files.copy(路径到路径)复制到临时目录,在 Windows 上会使用 CopyFileEx API 来处理被锁定的文件
- 备份会在复制前将所有区块刷入磁盘(
saveAllChunks)
- 通过
CompletableFuture 实现异步执行——无服务器 Tick 延迟
- 对于暂时被锁定的文件,采用递增退避的重试机制(最多 5 次尝试)
- 备份完成后(即使失败),临时目录也会自动清理
- 备份轮换按修改时间优先删除最旧的文件
- 安全的文件名验证:仅允许字母、数字、连字符和下划线
? 安装
- 为 Minecraft 1.21.1+ 安装 NeoForge
- 将
worldbackup-1.0.0.jar 放入 mods/ 文件夹
- 启动服务器——备份功能即可使用
无需额外配置即可开始使用。只需输入 /backup my-backup,一切就绪。
World Backup
Simple, reliable world backups at the press of a key — or the tip of a command.
Ever had your world corrupted by a rogue mod, a power outage, or just a bad decision with WorldEdit? World Backup lets you create instant, compressed zip backups of your entire world folder with a single command. Backups run asynchronously so your server never freezes, and automatic rotation keeps your disk from filling up.
✨ Features
- Instant backups — Create a full
.zip backup of your world with /backup <name>
- Non-blocking — Backups run on a separate thread; your server stays responsive
- Automatic rotation — Old backups are pruned automatically based on a configurable limit
- Configurable — Set your backup limit via command or JSON config file
- Safe by default — Name validation prevents path traversal attacks
- Conflict-friendly — Copies your world to a temp directory first, then zips from the clean copy. Files locked by other mods (Sable, etc.) are retried automatically with increasing backoff.
- Server-wide broadcast — All players see backup progress and completion messages
? Commands
| Command |
Description |
/backup <name> |
Creates a timestamped zip backup with the given name |
/backuplimit <number> |
Sets the maximum number of backups to keep (1–1000) |
Examples:
/backup before-portal → before-portal_2025-06-03_21-30-00.zip
/backup vanilla-test → vanilla-test_2025-06-03_21-31-15.zip
/backuplimit 25 → Sets the rotation limit to 25 backups
All players can use these commands by default — no operator permissions required.
⚙️ Configuration
The backup limit is stored in backup/backup_config.json inside your server directory. It is created automatically on first use and can be edited directly:
{
"backupLimit": 10
}
The limit can also be changed in-game with /backuplimit <number>.
? Where are backups stored?
Backups are saved to the backup/ folder inside your server directory (next to your world folders). Each backup is a compressed .zip file named in the format:
<name>_<YYYY-MM-DD_HH-mm-ss>.zip
? Compatibility
World Backup is designed to coexist peacefully with other mods:
- Sable — Fully compatible. World files are copied to a temporary directory before zipping, so Sable's file locks don't interfere. Retried up to 5 times with increasing backoff.
- Ice and Fire, Dread Land, and other dimension mods — All sub-levels and custom dimensions are backed up.
- Any file-locking mod — The copy-first strategy combined with retry logic handles files locked by other mods without skipping data.
- Any world type — Works with vanilla, modded, and custom world formats.
? Technical Details
- Copy-first strategy — World folder is copied to a temp directory using
Files.copy (path-to-path), which on Windows uses the CopyFileEx API to handle locked files
- Backups flush all chunks to disk before copying (
saveAllChunks)
- Asynchronous execution via
CompletableFuture — no server tick lag
- Automatic retry with backoff (up to 5 attempts) for temporarily locked files
- Temp directory is cleaned up automatically after backup completes (even on failure)
- Backup rotation deletes the oldest files first by modification time
- Safe filename validation: only letters, numbers, hyphens, and underscores allowed
? Installation
- Install NeoForge for Minecraft 1.21.1+
- Drop
worldbackup-1.0.0.jar into your mods/ folder
- Start the server — backups are ready to go
No configuration needed to get started. Just /backup my-backup and you're set.
评论 0
登录后参与评分
还没有评论,来抢沙发吧