Phase 6 part 2: restore from a backup
A restore is staged (checked, the current database backed up) and swapped in when the app next starts. Settings → Backups restores with a self-restart, cancels a waiting restore, and takes uploads; supermarket restore takes a backup name or a file; supermarket backup --with-secrets makes an archive with the keys, for moving machines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
<h2>Backups</h2>
|
||||
<p class="lede">Copies of Supermarket's database: your profile, inventory, signals, prospects, drafts, SEO and metrics. Each one is a single SQLite file. Your keys and tokens aren't in them; they stay in <code>secrets.json</code>.</p>
|
||||
|
||||
{{with .Restored}}<p class="ok">Restored from {{.From}} {{ago .At}}{{if .Secrets}}, keys and tokens included{{end}}. What was there before is backed up as {{.Backup}}.</p>{{end}}
|
||||
{{if .Pending}}
|
||||
<section class="card warn">
|
||||
<p><strong>A restore is waiting</strong> for Supermarket to restart. {{if not .CanRestart}}It's applied the next time Supermarket starts (<code>supermarket restart</code>).{{end}}</p>
|
||||
<form method="post" action="/settings/backups/cancel"><button type="submit" class="secondary small">Cancel the restore</button></form>
|
||||
</section>
|
||||
{{end}}
|
||||
<section class="card">
|
||||
<p>Supermarket backs up by itself once a day, and before every update that changes the database. The last 7 daily backups are kept, plus one a week for 4 weeks. The ones made before an update, before a restore, and the ones you make are kept until you delete them.</p>
|
||||
<form method="post" action="/settings/backups/now" class="inline-form">
|
||||
@@ -21,6 +28,8 @@
|
||||
<td class="num">{{bytes .Size}}</td>
|
||||
<td class="num">{{if ge .Schema 0}}{{.Schema}}{{else}}<span class="error-text" title="{{.Err}}">unreadable</span>{{end}}</td>
|
||||
<td><div class="row-actions">
|
||||
{{if ge .Schema 0}}{{if le .Schema $d.Schema}}<form method="post" action="/settings/backups/restore" data-confirm="Restore the backup from {{.At.Format "2 Jan 2006, 15:04"}}? Everything since then is replaced (it's backed up first), and Supermarket restarts.">
|
||||
<input type="hidden" name="name" value="{{.Name}}"><button type="submit" class="secondary small" data-busy="Restoring…">Restore</button></form>{{end}}{{end}}
|
||||
<a class="button secondary small" href="/settings/backups/file/{{.Name}}" download>Download</a>
|
||||
<form method="post" action="/settings/backups/delete" data-confirm="Delete the backup from {{.At.Format "2 Jan 2006, 15:04"}}?">
|
||||
<input type="hidden" name="name" value="{{.Name}}"><button type="submit" class="secondary small">Delete</button></form>
|
||||
@@ -30,4 +39,13 @@
|
||||
{{else}}
|
||||
<section class="card empty"><p>No backups yet. The first daily one is made when Supermarket starts.</p></section>
|
||||
{{end}}
|
||||
|
||||
<section class="card">
|
||||
<h3>Restore from a file</h3>
|
||||
<p class="help">A backup downloaded from here, on this computer or another. It's checked and added to the list; then restore it from there. For a backup made with <code>supermarket backup --with-secrets</code> (keys and tokens included), use <code>supermarket restore <file></code> in a terminal.</p>
|
||||
<form method="post" action="/settings/backups/upload" enctype="multipart/form-data" class="inline-form">
|
||||
<input type="file" name="file" accept=".db,application/vnd.sqlite3" required>
|
||||
<button type="submit" class="secondary" data-busy="Uploading…">Upload</button>
|
||||
</form>
|
||||
</section>
|
||||
{{end}}{{template "settings-end"}}{{end}}
|
||||
|
||||
Reference in New Issue
Block a user