release / govulncheck (push) Successful in 15s
release / web (push) Failing after 1m17s
release / go (push) Successful in 1m33s
release / integration (push) Successful in 5m16s
release / android (push) Successful in 5m56s
release / Build signed APK (push) Successful in 6m13s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
With "Include the music" on, each night's run sends the library files the destination doesn't hold yet, after the database file has landed, for up to six hours; a large library spans several nights the first time. Files keep their path under the library folders' common root, beside database/ in the same folder or bucket. backup_music_files records each file's size and mtime as sent, so a night sends only new and changed files, and a rescan that touches a track but finds the same file sends nothing. A changed file goes to its old name; Minstrel never deletes there. An object the bucket refuses (a locked overwrite) is kept with its answer and goes again once the file changes or the settings are saved; three refusals in a row stop the night's music, since that is a key that may not write under music/. A folder copy is written under a .part name and renamed, keeping the file's time. The panel shows how much of the library is in, the refused files, and each run's music count and note. The verdict still turns on the database file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
207 lines
7.1 KiB
Svelte
207 lines
7.1 KiB
Svelte
<script lang="ts">
|
|
import {
|
|
saveBackups,
|
|
testBackups,
|
|
type BackupConfig,
|
|
type BackupDestination,
|
|
type BackupStatus,
|
|
type BackupTestResult,
|
|
type BackupUpdate
|
|
} from '#lib/api/admin.js';
|
|
import { errMessage } from '#lib/api/errors.js';
|
|
import { pushToast } from '#lib/stores/toast.svelte.js';
|
|
import SettingsGroup from '#lib/components/settings/SettingsGroup.svelte';
|
|
import SettingRow from '#lib/components/settings/SettingRow.svelte';
|
|
import Segmented from '#lib/components/settings/Segmented.svelte';
|
|
import { plural } from '#lib/utils/plural.js';
|
|
import { hourLabel, when } from './backupTime.js';
|
|
|
|
// Where the nightly backup goes and when. The form keeps its own drafts,
|
|
// filled from the server on load and after each save, so a status poll
|
|
// never overwrites what is being typed.
|
|
|
|
let { config, onsaved }: { config: BackupConfig; onsaved: (s: BackupStatus) => void } = $props();
|
|
|
|
// svelte-ignore state_referenced_locally
|
|
let draft = $state(fromConfig(config));
|
|
// Empty means "keep the stored key". The key itself never comes back.
|
|
let secretKey = $state('');
|
|
let saving = $state(false);
|
|
let testing = $state(false);
|
|
let check = $state<BackupTestResult | null>(null);
|
|
let testError = $state('');
|
|
|
|
function fromConfig(c: BackupConfig) {
|
|
return {
|
|
enabled: c.enabled,
|
|
destination: c.destination,
|
|
folder: c.folder,
|
|
endpoint: c.endpoint,
|
|
bucket: c.bucket,
|
|
access_key: c.access_key,
|
|
run_hour: c.run_hour,
|
|
upload_limit_kib: c.upload_limit_kib,
|
|
include_music: c.include_music
|
|
};
|
|
}
|
|
|
|
const update = (): BackupUpdate => ({ ...draft, secret_key: secretKey.trim() });
|
|
|
|
const dirty = $derived(
|
|
secretKey.trim() !== '' || JSON.stringify(draft) !== JSON.stringify(fromConfig(config))
|
|
);
|
|
|
|
async function save() {
|
|
saving = true;
|
|
try {
|
|
const s = await saveBackups(update());
|
|
secretKey = '';
|
|
draft = fromConfig(s.config);
|
|
check = null;
|
|
onsaved(s);
|
|
pushToast('Backup settings saved.');
|
|
} catch (e) {
|
|
pushToast(errMessage(e), 'error');
|
|
} finally {
|
|
saving = false;
|
|
}
|
|
}
|
|
|
|
async function test() {
|
|
testing = true;
|
|
check = null;
|
|
testError = '';
|
|
try {
|
|
check = await testBackups(update());
|
|
} catch (e) {
|
|
testError = errMessage(e);
|
|
} finally {
|
|
testing = false;
|
|
}
|
|
}
|
|
|
|
const destinations: { value: BackupDestination; label: string }[] = [
|
|
{ value: 's3', label: 'S3 bucket' },
|
|
{ value: 'folder', label: 'Folder' }
|
|
];
|
|
const hours = Array.from({ length: 24 }, (_, h) => h);
|
|
|
|
const button =
|
|
'rounded-md border border-border px-3 py-1.5 text-sm text-text-secondary hover:bg-surface-hover hover:text-text-primary disabled:opacity-50';
|
|
const field = 'rounded-md border border-border bg-background px-3 py-1.5 text-sm';
|
|
</script>
|
|
|
|
<SettingsGroup
|
|
title="Backup settings"
|
|
id="backup-settings"
|
|
hint="Minstrel only ever adds backups. Thin out old ones with the destination's own retention."
|
|
>
|
|
<SettingRow label="Back up every night" for="backup-enabled" hint="Off until you switch it on.">
|
|
<input
|
|
id="backup-enabled"
|
|
type="checkbox"
|
|
role="switch"
|
|
aria-checked={draft.enabled}
|
|
bind:checked={draft.enabled}
|
|
class="h-4 w-4 cursor-pointer accent-accent"
|
|
/>
|
|
</SettingRow>
|
|
<SettingRow label="Destination">
|
|
<Segmented
|
|
name="backup-destination"
|
|
label="Destination"
|
|
options={destinations}
|
|
value={draft.destination}
|
|
onchange={(v) => (draft.destination = v)}
|
|
/>
|
|
</SettingRow>
|
|
|
|
{#if draft.destination === 'folder'}
|
|
<SettingRow label="Folder" for="backup-folder" hint="A full path on the server, such as a mounted volume.">
|
|
<input id="backup-folder" bind:value={draft.folder} placeholder="/backups" autocomplete="off" spellcheck="false" class="{field} w-56 font-mono" />
|
|
</SettingRow>
|
|
{:else}
|
|
<SettingRow label="Endpoint" for="backup-endpoint" hint="The bucket's server, path-style.">
|
|
<input
|
|
id="backup-endpoint"
|
|
bind:value={draft.endpoint}
|
|
placeholder="https://s3.example.com"
|
|
autocomplete="off"
|
|
spellcheck="false"
|
|
class="{field} w-56"
|
|
/>
|
|
</SettingRow>
|
|
<SettingRow label="Bucket" for="backup-bucket">
|
|
<input id="backup-bucket" bind:value={draft.bucket} placeholder="minstrel" autocomplete="off" spellcheck="false" class="{field} w-56" />
|
|
</SettingRow>
|
|
<SettingRow label="Access key" for="backup-access-key">
|
|
<input id="backup-access-key" bind:value={draft.access_key} autocomplete="off" spellcheck="false" class="{field} w-56 font-mono" />
|
|
</SettingRow>
|
|
<SettingRow label="Secret key" for="backup-secret-key" hint="Kept encrypted on the server.">
|
|
<input
|
|
id="backup-secret-key"
|
|
type="password"
|
|
autocomplete="new-password"
|
|
bind:value={secretKey}
|
|
placeholder={config.has_secret_key ? 'Key saved' : 'Paste key'}
|
|
class="{field} w-56 font-mono"
|
|
/>
|
|
</SettingRow>
|
|
<SettingRow label="Upload limit" for="backup-limit" hint="KiB a second, so an upload leaves room on the connection. 0 is no limit.">
|
|
<input id="backup-limit" type="number" min="0" step="256" bind:value={draft.upload_limit_kib} class="{field} w-28" />
|
|
</SettingRow>
|
|
{/if}
|
|
|
|
<SettingRow
|
|
label="Include the music"
|
|
for="backup-music"
|
|
hint="Each file goes once, and again only when it changes. A large library takes several nights the first time."
|
|
>
|
|
<input
|
|
id="backup-music"
|
|
type="checkbox"
|
|
role="switch"
|
|
aria-checked={draft.include_music}
|
|
bind:checked={draft.include_music}
|
|
class="h-4 w-4 cursor-pointer accent-accent"
|
|
/>
|
|
</SettingRow>
|
|
{#if draft.include_music}
|
|
<p class="px-4 pb-2 text-xs text-text-secondary" data-testid="backup-music-retention">
|
|
A changed file goes to the same name. On a bucket that keeps versions or locks objects, set its retention to
|
|
keep only what you want.
|
|
</p>
|
|
{/if}
|
|
|
|
<SettingRow label="Time of day" for="backup-hour" hint="On your clock.">
|
|
<select id="backup-hour" bind:value={draft.run_hour} class={field}>
|
|
{#each hours as h (h)}
|
|
<option value={h}>{hourLabel(h)}</option>
|
|
{/each}
|
|
</select>
|
|
</SettingRow>
|
|
|
|
<div class="space-y-2 px-4 py-3">
|
|
<div class="flex flex-wrap items-center justify-end gap-2">
|
|
<button type="button" class={button} disabled={testing} onclick={test}>
|
|
{testing ? 'Testing…' : 'Test destination'}
|
|
</button>
|
|
<button type="button" class={button} disabled={!dirty || saving} onclick={save}>
|
|
{saving ? 'Saving…' : 'Save'}
|
|
</button>
|
|
</div>
|
|
{#if testError}
|
|
<p class="text-sm text-error-fg" role="alert" data-testid="backup-test">{testError}</p>
|
|
{:else if check}
|
|
<p class="text-sm text-success-fg" role="status" data-testid="backup-test">
|
|
Reached it.
|
|
{#if check.backups === 0}
|
|
No backups there yet.
|
|
{:else}
|
|
{plural(check.backups, 'backup', 'backups')} there, the newest from {when(check.latest!)}.
|
|
{/if}
|
|
</p>
|
|
{/if}
|
|
</div>
|
|
</SettingsGroup>
|