Rollback: restore a server's world from any of its backups, with a Current marker

Manage gets a Backup section (between World and Logs) listing the server's automatic and manual
backups. Rolling back is only allowed while the server is stopped and nothing else, such as an
automatic backup, is running on it; the server claims the busy flag atomically so the two can't race.
A run players were on is backed up first. The new world is extracted to a staging folder and checked
before the old one is deleted.

The backup that holds the world as it is now is marked Current (its button is disabled, and the
Backups page tags it). It's tracked in backups/<game>/<container>.current: set by automatic backups
and rollbacks, none while players have been on, newest automatic backup when there's no record.
Rolling back to an automatic backup can keep the Current backup as a manual one (or make one if
nothing is current), warning when that pushes out the oldest of 5 manual backups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-02 22:53:25 -08:00
parent 87b92f8332
commit 51db28f3d5
No known key found for this signature in database
5 changed files with 429 additions and 12 deletions

View file

@ -97,6 +97,17 @@
<li>While the server is running this is its last autosave (Valheim saves about every 30 minutes). Stop the
server first for an up-to-the-minute copy.</li>
</ul>
<h3>Rolling back</h3>
<ul class="about-list">
<li>Use the <b>Backup</b> section of a server's Manage panel to replace its world with one of its backups.
The server must be stopped, and rolling back waits until any automatic backup in progress has finished.</li>
<li>If players were on since the last automatic backup, that world is backed up automatically first.</li>
<li>Rolling back to an <b>automatic</b> backup can keep the world you roll back from (the <b>Current</b> backup)
as a manual backup, so you can return to it later without newer automatic backups pushing it out.</li>
<li>The backup marked <b>Current</b> holds the server's world as it is now, so it can't be rolled back to. That's
the newest automatic backup, or the backup last rolled back to. Once players join, the world moves past every
backup and nothing is marked Current until the next automatic backup.</li>
</ul>
<h3>Retention</h3>
<ul class="about-list">
<li>The newest <b>5 automatic</b> and newest <b>5 manual</b> backups are kept for each server. Older ones are
@ -237,6 +248,14 @@
</div>
</div>
<div class="manage-section hidden" id="rollback-section">
<h3>Backup</h3>
<p class="muted small" style="margin-top:0">Roll the world back to one of this server's automatic or manual backups.
Stop the server first: rolling back is only available while it is stopped and no backup is being made.</p>
<div id="rollback-list"></div>
<div id="rollback-messages" class="msgs"></div>
</div>
<div class="manage-section">
<h3>Logs</h3>
<div class="row-between"><span class="muted small">Live, color-coded output from the game server.</span><button class="ghost" id="manage-logs">View logs</button></div>
@ -249,6 +268,26 @@
</div>
</dialog>
<!-- Rollback confirmation -->
<dialog id="rollback-dialog">
<h2 style="margin-top:0" id="rollback-title">Roll back?</h2>
<p id="rollback-what"></p>
<div id="rollback-promote" class="hidden">
<label class="radio"><input type="checkbox" id="rollback-promote-check" checked> Keep the world I'm rolling back from as a manual backup</label>
<p class="muted small" id="rollback-promote-help"></p>
<p class="msg msg-warning hidden" id="rollback-promote-full"></p>
</div>
<p class="msg msg-info hidden" id="rollback-kept-note"></p>
<p class="muted small" id="rollback-running"></p>
<p class="msg msg-warning hidden" id="rollback-blocked"></p>
<p class="error" id="rollback-error"></p>
<div class="wiz-actions">
<button type="button" class="ghost" id="rollback-cancel">Cancel</button>
<span class="spacer"></span>
<button type="button" class="danger" id="rollback-confirm">Roll back</button>
</div>
</dialog>
<!-- Mod manager (Project Zomboid) -->
<dialog id="mods-dialog" class="wide">
<div class="logs-head">