8.2 KiB
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.saveEverythingcallsPlayerList.saveAllbefore applying the chunk-saving flags.PlayerList.remove(ServerPlayer)callssave(player)during logout without consulting the world'snoSaveflag.MinecraftServer.saveAllChunksalso writes the main world metadata usingLevelStorageAccess.saveDataTagoutside the per-level skip-save logic.- Sable's
sable$saveSubLevelsinjection runs beforeServerLevel.saveLevelData, inside the level's skip-save guard. That particular hook is not evidence that Sable ignoressave-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:
/var/lib/minecraft-backups/s3-credentials
Its contents use the systemd environment-file format:
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:
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.
Isolated wowMineMap restore test
Neuro declares wowMineMapRestore as a separate, manually started Minecraft
instance. It reuses the production NeoForge package, pinned WorldOfSosal
modpack import, and shared modpack adjustments. It uses an 8 GB heap and reduced
view/simulation distances for the test. Its directory is
/srv/minecraft/wowMineMapRestore; its game socket is 127.0.0.1:25568.
RCON, public firewall access, and scheduled backups of this copy are disabled.
It does not use the production source-map importer or reset service.
After deploying the neuro NixOS configuration normally, start the copy:
ssh neuro 'systemctl start minecraft-server-wowMineMapRestore.service'
ssh neuro 'journalctl -u minecraft-modpack-import-wowMineMapRestore -u minecraft-backup-restore-wowMineMapRestore -u minecraft-server-wowMineMapRestore -n 100 --no-pager'
ssh neuro 'tail -n 80 /srv/minecraft/wowMineMapRestore/logs/latest.log'
The first start installs the matching modpack, then downloads this exact object:
s3://backup-hectic-lab/minecraft/neuro/wowMineMap/minecraft-wowMineMap-20261117T172531Z.tar.zst
The restore uses the existing root-only S3 credentials file. The key needs
GetObject access in addition to the backup permissions above. It checks the
compressed size (9,206,330,929 bytes), zstd integrity, archive paths, and the
configured world's level.dat. Backup data, including player and mod state,
overrides bootstrap configuration; regenerated mods remain installed.
It refuses to replace an existing world. A completion marker binds the
restored directory to this S3 object, and subsequent starts skip both bootstrap
and restoration so that restored configuration is preserved.
Connect using the matching WorldOfSosal client through an SSH tunnel:
ssh -N -L 25568:127.0.0.1:25568 neuro
Use localhost:25568 in Minecraft. Confirm startup reaches Done, enter the
restored Azeroth dimension, and inspect known builds, player inventory, and mod
objects. A running systemd unit alone does not prove that the saved world
loaded correctly. These real-world checks remain to be performed after deploy.
Stop the test when finished:
ssh neuro 'systemctl stop minecraft-server-wowMineMapRestore.service'