[PR #553] [MERGED] horizon-server: backups, restore and automatic backups #2637

Closed
opened 2026-11-02 15:57:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/553
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: feat/horizon-server-backups


📝 Commits (6)

  • 9d21209 horizon-server: server.toml, init, and a supervisor that runs the game
  • e883219 horizon-server: start, stop, status, cmd and logs through a local control API
  • 3510764 horizon-server: backups, restore and automatic backups
  • 07f7e3a Merge remote-tracking branch 'origin/main' into srv-fix
  • 2483f90 Merge feat/horizon-server into feat/horizon-server-control
  • 500241c Merge feat/horizon-server-control into feat/horizon-server-backups

📊 Changes

25 files changed (+3426 additions, -6 deletions)

View changed files

📝 Cargo.lock (+27 -0)
📝 Cargo.toml (+1 -1)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/src/game/dedicated.rs (+30 -0)
➕ crates/horizon-client/src/game/dedicated/status.rs (+100 -0)
📝 crates/horizon-client/src/lib.rs (+1 -1)
➕ crates/horizon-server-files/Cargo.toml (+16 -0)
📝 crates/horizon-server-files/src/eula.rs (+6 -1)
📝 crates/horizon-server-files/src/java_properties.rs (+0 -0)
📝 crates/horizon-server-files/src/json.rs (+0 -0)
📝 crates/horizon-server-files/src/lib.rs (+3 -3)
📝 crates/horizon-server-files/src/properties.rs (+0 -0)
📝 crates/horizon-server-files/src/user_lists.rs (+0 -0)
➕ crates/horizon-server/Cargo.toml (+29 -0)
➕ crates/horizon-server/src/api.rs (+453 -0)
➕ crates/horizon-server/src/backup.rs (+332 -0)
➕ crates/horizon-server/src/cli.rs (+415 -0)
➕ crates/horizon-server/src/config.rs (+544 -0)
➕ crates/horizon-server/src/engine.rs (+182 -0)
➕ crates/horizon-server/src/http.rs (+219 -0)

...and 5 more files

📄 Description

PR 2c of docs/server.md (section 11), stacked on #552: backups and restore.

What it does

  • backup [NAME] zips the world, the vanilla files and server.toml into backups/<time>-<name>.zip.
    • On a running server it runs save-off and save-all flush through the game, zips, then runs save-on. Players stay online.
    • A stopped server is backed up straight from its files.
    • The zip is written to a temporary name and renamed when complete, so a crash never leaves a half backup.
  • restore BACKUP takes the file name, a unique prefix, or the name given to backup (the newest with it).
    • The current world is moved to backups/replaced-<time>/, never deleted.
    • The backup is unpacked aside and checked (level.dat) before it goes in place.
    • A running server restarts with it, and the command waits until the game is back.
  • backups lists them, newest first.
  • [backups] every = "6h", keep = 12 back up on a schedule while the game runs and prune only the automatic backups; backups made by hand are never deleted.
  • The control API gains GET/POST /api/v1/backups and POST /api/v1/restore.

Tested by hand

On a running server:

  1. setblock 0 100 0 gold_block, then backup before-change (0.3 s, 5 MB).
  2. Set the block to air.
  3. restore before-change --yes restarted the game in 12 s, and execute if block 0 100 0 gold_block passed. The replaced world sat in backups/replaced-….

With every = "1m" an automatic backup appeared on time. An offline backup worked too.

Checks

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean on every branch of the stack.
  • Tests: cargo test -p horizon-server -p horizon-server-files pass on every branch (16 server tests in 2a, 24 at the tip). horizon-server also passes clippy and its tests on Linux (the ThinkPad).
  • Parity at the stack's tip (2a–3), rebased on b4ad6538:
    • tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage: 5 passed, 0 failed. dedicated_server includes vanilla's protocol client joining Horizon's server.
    • The full --changed origin/main set (309 harnesses, because the client crate changes) had 60 passed, 0 failed when it was stopped. The Mac mini was running out of disk, and at about 1 harness a minute the run needed 4 more hours. CI's parity covers the rest.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/553 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/horizon-server-backups` --- ### 📝 Commits (6) - [`9d21209`](https://github.com/horizon-rust/horizon/commit/9d21209ae8c4e6f788955abab69e7b96d1ef3237) horizon-server: server.toml, init, and a supervisor that runs the game - [`e883219`](https://github.com/horizon-rust/horizon/commit/e8832190d1017de6d23eb66c0b8dc75ca35cc95f) horizon-server: start, stop, status, cmd and logs through a local control API - [`3510764`](https://github.com/horizon-rust/horizon/commit/3510764cc645989ca3cd993310cbcaa1787e7e94) horizon-server: backups, restore and automatic backups - [`07f7e3a`](https://github.com/horizon-rust/horizon/commit/07f7e3aeab80a1d3d3c76ef5b643eaaf1fa48fde) Merge remote-tracking branch 'origin/main' into srv-fix - [`2483f90`](https://github.com/horizon-rust/horizon/commit/2483f90779fa37882f4a3ceb3073fb9947e5e22b) Merge feat/horizon-server into feat/horizon-server-control - [`500241c`](https://github.com/horizon-rust/horizon/commit/500241cbc6563fdf0ff27cf4dbd36e57fccd9f71) Merge feat/horizon-server-control into feat/horizon-server-backups ### 📊 Changes **25 files changed** (+3426 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+27 -0) 📝 `Cargo.toml` (+1 -1) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/src/game/dedicated.rs` (+30 -0) ➕ `crates/horizon-client/src/game/dedicated/status.rs` (+100 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -1) ➕ `crates/horizon-server-files/Cargo.toml` (+16 -0) 📝 `crates/horizon-server-files/src/eula.rs` (+6 -1) 📝 `crates/horizon-server-files/src/java_properties.rs` (+0 -0) 📝 `crates/horizon-server-files/src/json.rs` (+0 -0) 📝 `crates/horizon-server-files/src/lib.rs` (+3 -3) 📝 `crates/horizon-server-files/src/properties.rs` (+0 -0) 📝 `crates/horizon-server-files/src/user_lists.rs` (+0 -0) ➕ `crates/horizon-server/Cargo.toml` (+29 -0) ➕ `crates/horizon-server/src/api.rs` (+453 -0) ➕ `crates/horizon-server/src/backup.rs` (+332 -0) ➕ `crates/horizon-server/src/cli.rs` (+415 -0) ➕ `crates/horizon-server/src/config.rs` (+544 -0) ➕ `crates/horizon-server/src/engine.rs` (+182 -0) ➕ `crates/horizon-server/src/http.rs` (+219 -0) _...and 5 more files_ </details> ### 📄 Description PR 2c of [docs/server.md](https://github.com/ludovic111/horizon/pull/557) (section 11), stacked on #552: backups and restore. ## What it does - **`backup [NAME]`** zips the world, the vanilla files and `server.toml` into `backups/<time>-<name>.zip`. - On a running server it runs `save-off` and `save-all flush` through the game, zips, then runs `save-on`. Players stay online. - A stopped server is backed up straight from its files. - The zip is written to a temporary name and renamed when complete, so a crash never leaves a half backup. - **`restore BACKUP`** takes the file name, a unique prefix, or the name given to `backup` (the newest with it). - The current world is moved to `backups/replaced-<time>/`, never deleted. - The backup is unpacked aside and checked (`level.dat`) before it goes in place. - A running server restarts with it, and the command waits until the game is back. - **`backups`** lists them, newest first. - **`[backups] every = "6h"`, `keep = 12`** back up on a schedule while the game runs and prune only the automatic backups; backups made by hand are never deleted. - The control API gains `GET/POST /api/v1/backups` and `POST /api/v1/restore`. ## Tested by hand On a running server: 1. `setblock 0 100 0 gold_block`, then `backup before-change` (0.3 s, 5 MB). 2. Set the block to air. 3. `restore before-change --yes` restarted the game in 12 s, and `execute if block 0 100 0 gold_block` passed. The replaced world sat in `backups/replaced-…`. With `every = "1m"` an automatic backup appeared on time. An offline backup worked too. ## Checks - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean on every branch of the stack. - Tests: `cargo test -p horizon-server -p horizon-server-files` pass on every branch (16 server tests in 2a, 24 at the tip). horizon-server also passes clippy and its tests on Linux (the ThinkPad). - Parity at the stack's tip (2a–3), rebased on b4ad6538: - `tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage`: **5 passed, 0 failed**. `dedicated_server` includes vanilla's protocol client joining Horizon's server. - The full `--changed origin/main` set (309 harnesses, because the client crate changes) had **60 passed, 0 failed** when it was stopped. The Mac mini was running out of disk, and at about 1 harness a minute the run needed 4 more hours. CI's parity covers the rest. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:50 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2637
No description provided.