backups for mine
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
- [Minecraft incident log](./minecraft-incidents.md)
|
||||
- [WorldOfSosal source versions and reset](./world-of-sosal-reset.md)
|
||||
- [Project Zomboid backups](./project-zomboid-backups.md)
|
||||
- [Minecraft backups](./minecraft-backups.md)
|
||||
- [Gitea Kanban CLI](./gitea-kanban-cli.md)
|
||||
- [AFFiNE document typography](./affine-typography.md)
|
||||
- [Native AFFiNE deployment and migration](./affine-native.md)
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
# Minecraft backups
|
||||
|
||||
`services.minecraft-backups` adds scheduled S3 archives to the Minecraft module.
|
||||
Neuro enables it for `vanilla`, `createAeronautics`, `wowMineMap`, and Horizon.
|
||||
Enabled nix-minecraft servers are discovered automatically. Horizon is registered
|
||||
explicitly because it runs a separate native engine.
|
||||
|
||||
Each server has a `minecraft-backup-<name>.timer`, scheduled every six hours
|
||||
with up to ten minutes of jitter. S3 retains regular timestamped archives for
|
||||
14 days under `minecraft/neuro/<name>/` in `backup-hectic-lab`.
|
||||
Horizon also keeps its existing native backups.
|
||||
|
||||
Set `services.minecraft-backups.onCalendar` to change the schedule. Its default
|
||||
is `"*-*-* 00/6:00:00"` (00:00, 06:00, 12:00, and 18:00 in the host timezone).
|
||||
S3 retention is configured separately with `services.minecraft-backups.s3.retentionDays`.
|
||||
|
||||
## Snapshot and local storage
|
||||
|
||||
A running server is shut down through its normal systemd stop command while
|
||||
rsync copies its data to a private staging directory. A failed or forced
|
||||
shutdown prevents the snapshot. The server starts again before compression
|
||||
or upload. An already inactive server stays inactive.
|
||||
|
||||
An exit trap and the backup unit's `ExecStopPost` restore a server that the backup
|
||||
stopped if copying fails or the backup is terminated. A `restart-needed` marker
|
||||
persists until starting the server succeeds.
|
||||
|
||||
Staging and pending archives live in `/var/lib/minecraft-backups/<name>/`.
|
||||
Staging remains for the next incremental copy. A completed archive is removed
|
||||
locally only after a successful upload. Failed uploads leave it for the next
|
||||
run, which retries pending archives before taking another snapshot.
|
||||
|
||||
Archives contain server data, including worlds and runtime lists such as
|
||||
whitelists and operators. Regenerated mods, libraries, resources, caches,
|
||||
logs, existing backups, and secret-bearing `server.properties` are excluded.
|
||||
Reapply the matching Nix configuration when restoring.
|
||||
|
||||
S3 cleanup only deletes names matching that server's timestamped archive format.
|
||||
Manual archives and other prefixes are preserved. Cleanup uses the same helper
|
||||
as PZ: individual object deletions and explicit validation of S3 deletion errors.
|
||||
|
||||
## wowMineMap live-backup investigation, 2026-11-16
|
||||
|
||||
Read-only inspection through `ssh neuro` confirmed that wowMineMap is running
|
||||
Minecraft 1.21.1 / NeoForge 21.1.250 with Sable 2.0.5 and Distant Horizons 3.3.3.
|
||||
Its data resides on ext4 at `/dev/nvme0n1p2`; there is no configured snapshot
|
||||
backend for this mount.
|
||||
|
||||
The Java process has seven Distant Horizons SQLite databases open across the
|
||||
dimensions, including their WAL and shared-memory files. The Azeroth main
|
||||
database was about 2.2 GB with a separate nonempty WAL. Copying these files
|
||||
independently is not a database snapshot.
|
||||
|
||||
One component was verified without stopping the game: Python's SQLite Backup
|
||||
API copied `world/data/DistantHorizons.sqlite`, opened with `mode=ro`, into an
|
||||
in-memory database. The copy reported journal mode `wal`, 1286 pages, six tables,
|
||||
and `PRAGMA quick_check` returned `ok`. No backup file was written on neuro.
|
||||
This verifies that database-copy mechanism, not a full-world restore.
|
||||
|
||||
Inspection with `javap` of the deployed Minecraft server and Sable jars found:
|
||||
|
||||
- `MinecraftServer.saveEverything` calls `PlayerList.saveAll` before applying
|
||||
the chunk-saving flags.
|
||||
- `PlayerList.remove(ServerPlayer)` calls `save(player)` during logout without
|
||||
consulting the world's `noSave` flag.
|
||||
- `MinecraftServer.saveAllChunks` also writes the main world metadata using
|
||||
`LevelStorageAccess.saveDataTag` outside the per-level skip-save logic.
|
||||
- Sable's `sable$saveSubLevels` injection runs before `ServerLevel.saveLevelData`,
|
||||
inside the level's skip-save guard. That particular hook is not evidence that
|
||||
Sable ignores `save-off`.
|
||||
|
||||
Consequently, `save-off` plus `save-all flush` does not make the entire server
|
||||
directory immutable while players keep playing. A file copy can combine frozen
|
||||
chunks with later player inventories or world metadata. SQLite snapshots alone
|
||||
do not provide a common checkpoint for those different data stores.
|
||||
|
||||
No live mode with guarantees equivalent to an orderly stopped-server copy has
|
||||
been established for this pack. The stop-based implementation has therefore
|
||||
not been replaced or deployed. A full-world live restore test was not run,
|
||||
because there is not yet a coordinated snapshot mechanism to test.
|
||||
|
||||
The next implementation step would be an in-process NeoForge checkpoint that
|
||||
coordinates world, player, Sable, and SQLite persistence, followed by a restore
|
||||
test on a disposable WorldOfSosal instance. Production was not stopped,
|
||||
restarted, sent save commands, or deployed during this investigation; the
|
||||
six-hour schedule and fourteen-day retention remain unchanged.
|
||||
|
||||
## Credentials and deployment
|
||||
|
||||
Before enabling the timers on neuro, provision a root-owned file with mode 0600:
|
||||
|
||||
```text
|
||||
/var/lib/minecraft-backups/s3-credentials
|
||||
```
|
||||
|
||||
Its contents use the systemd environment-file format:
|
||||
|
||||
```sh
|
||||
AWS_ACCESS_KEY_ID=...
|
||||
AWS_SECRET_ACCESS_KEY=...
|
||||
```
|
||||
|
||||
The key must allow listing the bucket and uploading/deleting objects under
|
||||
`minecraft/neuro/`. Keep the file outside the repository and `/nix/store`.
|
||||
A missing file prevents the backup from starting, before it stops any server.
|
||||
|
||||
The committed configuration does not provision this secret. Apply the neuro
|
||||
configuration after the file exists, then check:
|
||||
|
||||
```sh
|
||||
systemctl list-timers 'minecraft-backup-*'
|
||||
systemctl start minecraft-backup-vanilla.service
|
||||
journalctl -u minecraft-backup-vanilla.service
|
||||
```
|
||||
|
||||
## Restore
|
||||
|
||||
Stop that server's backup timer and game service. Download the chosen
|
||||
`minecraft-<name>-<timestamp>.tar.zst` from its S3 prefix. Preserve the current
|
||||
data directory separately before replacing anything.
|
||||
|
||||
Extract the archive into the server's data directory while the game is stopped.
|
||||
Archives contain paths relative to that directory. Restore file ownership to the
|
||||
game service's user (`minecraft` for Java servers, `horizon` for Horizon),
|
||||
reapply the matching Nix configuration and runtime secrets, then start the game
|
||||
and its backup timer.
|
||||
Reference in New Issue
Block a user