fix: surface backup restore progress
Build and publish Docker image / build-and-publish (push) Successful in 13s

This commit is contained in:
wfalkowski committed 2026-10-24 06:38:44 +00:00
1 parent c0d511f83a
commit 1cc954a665
2 files changed
+70 -26

No files matched your search

+56 -26
View File
@@ -13,6 +13,9 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
const [backups, setBackups] = useState([]); const [backups, setBackups] = useState([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [creating, setCreating] = useState(false); const [creating, setCreating] = useState(false);
const [restoring, setRestoring] = useState(false);
const [restoreStatus, setRestoreStatus] = useState('');
const [restoreBackupId, setRestoreBackupId] = useState(null);
const [backupName, setBackupName] = useState(''); const [backupName, setBackupName] = useState('');
const [showCreateForm, setShowCreateForm] = useState(false); const [showCreateForm, setShowCreateForm] = useState(false);
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
@@ -53,30 +56,30 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
} }
} else if (data.type === 'backup_deleted') { } else if (data.type === 'backup_deleted') {
setBackups(prev => prev.filter(b => b.id !== data.backupId)); setBackups(prev => prev.filter(b => b.id !== data.backupId));
} else if (data.type === 'info' && data.message.includes('Restoration')) { } else if (data.type === 'info' && data.backupId === restoreBackupId) {
// Optional: handle restoration progress info messages if needed setRestoreStatus(data.message || 'Restoring backup…');
if (data.message?.includes('Restoration completed successfully')) {
setRestoring(false);
}
} else if (data.type === 'error' && data.backupId === restoreBackupId) {
setRestoring(false);
setRestoreStatus('Restore stopped. See the error message for details.');
} else if (data.type === 'error' && data.serverId === serverId && !data.backupId) {
setCreating(false);
setLoading(false);
} }
} }
} catch (e) { } catch (e) {
console.error("Error processing backup message:", e); console.error("Error processing backup message:", e);
} }
} }
}, [lastMessage, serverId]); }, [lastMessage, serverId, restoreBackupId]);
const handleCreateBackup = () => {
if (creating) return;
setCreating(true);
sendMessage({
type: 'create_backup',
serverId: serverId,
name: backupName || undefined
});
setBackupName('');
setShowCreateForm(false);
};
const handleRestore = (backupId) => { const handleRestore = (backupId) => {
if (window.confirm("ARE YOU SURE? This will overwrite the current server data with this backup. The server will be stopped during restoration.")) { if (window.confirm("ARE YOU SURE? This will overwrite the current server data with this backup. The server will be stopped during restoration.")) {
setRestoreBackupId(backupId);
setRestoring(true);
setRestoreStatus('Preparing restore…');
sendMessage({ sendMessage({
type: 'restore_backup', type: 'restore_backup',
serverId: serverId, serverId: serverId,
@@ -95,10 +98,23 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
} }
}; };
const handleCreateBackup = () => {
if (creating || restoring) return;
setCreating(true);
sendMessage({
type: 'create_backup',
serverId: serverId,
name: backupName || undefined
});
setBackupName('');
setShowCreateForm(false);
};
const getStatusColor = (status) => { const getStatusColor = (status) => {
switch (status) { switch (status) {
case 'Completed': return colors.green; case 'Completed': return colors.green;
case 'Failed': return colors.red; case 'Failed': return colors.red;
case 'Unavailable': return colors.yellow;
case 'In Progress': return colors.yellow; case 'In Progress': return colors.yellow;
default: return colors.foreground; default: return colors.foreground;
} }
@@ -114,7 +130,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
}; };
const filteredBackups = backups.filter(b => const filteredBackups = backups.filter(b =>
b.name.toLowerCase().includes(searchTerm.toLowerCase()) || (b.name || '').toLowerCase().includes(searchTerm.toLowerCase()) ||
(b.id && b.id.toLowerCase().includes(searchTerm.toLowerCase())) (b.id && b.id.toLowerCase().includes(searchTerm.toLowerCase()))
); );
@@ -126,7 +142,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<Database className="w-6 h-6 text-primary" /> <Database className="w-6 h-6 text-primary" />
Backups & Snapshots Backups & Snapshots
</h3> </h3>
<p className="text-sm opacity-60 mt-1">Restore your server from automated or manual points in time.</p> <p className="text-sm opacity-60 mt-1">Create a manual restore point before making important changes.</p>
</div> </div>
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
@@ -149,7 +165,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton <ActionButton
variant="primary" variant="primary"
onClick={() => setShowCreateForm(true)} onClick={() => setShowCreateForm(true)}
disabled={creating} disabled={creating || restoring}
className="whitespace-nowrap shadow-lg shadow-primary/20" className="whitespace-nowrap shadow-lg shadow-primary/20"
> >
<Plus className="w-4 h-4" /> <Plus className="w-4 h-4" />
@@ -158,6 +174,18 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
</div> </div>
</div> </div>
{restoring && (
<div className="rounded-xl border px-4 py-3 text-sm" style={{ borderColor: `${colors.primary}55`, color: colors.foreground, backgroundColor: `${colors.primary}10` }} role="status" aria-live="polite">
<span className="inline-flex items-center gap-2"><RefreshCw className="w-4 h-4 animate-spin" />{restoreStatus || 'Restoring backup…'}</span>
<p className="mt-1 opacity-70">Keep this page open. The server remains stopped until its restored storage is ready.</p>
</div>
)}
{!restoring && restoreStatus && (
<div className="rounded-xl border px-4 py-3 text-sm" style={{ borderColor: `${colors.yellow}55`, color: colors.foreground, backgroundColor: `${colors.yellow}10` }} role="status">
{restoreStatus}
</div>
)}
{showCreateForm && ( {showCreateForm && (
<SectionCard title="New Manual Backup" icon={Plus} color={colors.primary} className="animate-in slide-in-from-top-4 duration-300"> <SectionCard title="New Manual Backup" icon={Plus} color={colors.primary} className="animate-in slide-in-from-top-4 duration-300">
<div className="flex flex-col sm:flex-row gap-4"> <div className="flex flex-col sm:flex-row gap-4">
@@ -177,7 +205,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton onClick={() => setShowCreateForm(false)} variant="secondary" className="flex-1 sm:flex-none"> <ActionButton onClick={() => setShowCreateForm(false)} variant="secondary" className="flex-1 sm:flex-none">
Cancel Cancel
</ActionButton> </ActionButton>
<ActionButton onClick={handleCreateBackup} variant="primary" disabled={creating} className="flex-1 sm:flex-none"> <ActionButton onClick={handleCreateBackup} variant="primary" disabled={creating || restoring} className="flex-1 sm:flex-none">
{creating ? <RefreshCw className="w-4 h-4 animate-spin" /> : <CheckCircle className="w-4 h-4" />} {creating ? <RefreshCw className="w-4 h-4 animate-spin" /> : <CheckCircle className="w-4 h-4" />}
{creating ? 'Creating...' : 'Start Backup'} {creating ? 'Creating...' : 'Start Backup'}
</ActionButton> </ActionButton>
@@ -194,7 +222,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<DashboardEmptyState <DashboardEmptyState
icon={Database} icon={Database}
title="No backups found" title="No backups found"
description="You haven't created any backups yet. Manual backups are stored as snapshots directly on our high-performance storage." description="You haven't created any backups yet. Create a manual snapshot before a software update or other risky change."
action={ action={
<ActionButton variant="primary" onClick={() => setShowCreateForm(true)}> <ActionButton variant="primary" onClick={() => setShowCreateForm(true)}>
Create your first backup Create your first backup
@@ -213,11 +241,12 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<div className={`p-3 rounded-xl border transition-colors duration-200 ${ <div className={`p-3 rounded-xl border transition-colors duration-200 ${
backup.status === 'In Progress' ? 'bg-yellow-500/10 border-yellow-500/20' : backup.status === 'In Progress' ? 'bg-yellow-500/10 border-yellow-500/20' :
backup.status === 'Failed' ? 'bg-red-500/10 border-red-500/20' : backup.status === 'Failed' ? 'bg-red-500/10 border-red-500/20' :
backup.status === 'Unavailable' ? 'bg-yellow-500/10 border-yellow-500/20' :
'bg-primary/10 border-primary/20' 'bg-primary/10 border-primary/20'
}`}> }`}>
{backup.status === 'In Progress' ? ( {backup.status === 'In Progress' ? (
<RefreshCw className="w-6 h-6 text-yellow-500 animate-spin" /> <RefreshCw className="w-6 h-6 text-yellow-500 animate-spin" />
) : backup.status === 'Failed' ? ( ) : backup.status === 'Failed' || backup.status === 'Unavailable' ? (
<AlertTriangle className="w-6 h-6 text-red-500" /> <AlertTriangle className="w-6 h-6 text-red-500" />
) : ( ) : (
<ShieldCheck className="w-6 h-6 text-primary" /> <ShieldCheck className="w-6 h-6 text-primary" />
@@ -248,6 +277,9 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
{backup.status.toUpperCase()} {backup.status.toUpperCase()}
</span> </span>
</div> </div>
{backup.unavailableReason && (
<p className="mt-2 text-xs text-red-400">{backup.unavailableReason}</p>
)}
</div> </div>
</div> </div>
@@ -256,7 +288,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton <ActionButton
variant="secondary" variant="secondary"
onClick={() => handleRestore(backup.id)} onClick={() => handleRestore(backup.id)}
disabled={backup.status !== 'Completed' || creating} disabled={backup.status !== 'Completed' || creating || restoring}
className="flex-1 md:flex-none h-10 min-h-0" className="flex-1 md:flex-none h-10 min-h-0"
> >
<RotateCcw className="w-4 h-4" /> <RotateCcw className="w-4 h-4" />
@@ -268,7 +300,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton <ActionButton
variant="danger" variant="danger"
onClick={() => handleDelete(backup.id)} onClick={() => handleDelete(backup.id)}
disabled={backup.status === 'In Progress'} disabled={backup.status === 'In Progress' || restoring}
className="px-3 h-10 min-h-0" className="px-3 h-10 min-h-0"
> >
<Trash2 className="w-4 h-4" /> <Trash2 className="w-4 h-4" />
@@ -293,9 +325,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<div> <div>
<h5 className="font-bold text-sm mb-1" style={{ color: colors.brightWhite }}>Data Integrity & Retention</h5> <h5 className="font-bold text-sm mb-1" style={{ color: colors.brightWhite }}>Data Integrity & Retention</h5>
<p className="text-xs text-dash-textMuted leading-relaxed"> <p className="text-xs text-dash-textMuted leading-relaxed">
Manual backups are kept indefinitely until deleted. Automated daily snapshots are retained for 7 days. Manual backups remain available until you delete them. Each backup is stored as a volume snapshot. Restoring one replaces the current server data and stops the server while storage is rebuilt.
All data is stored as snapshots within our cluster to ensure near-instant restoration.
Restoring a backup will temporarily stop the server while data is being synchronized.
</p> </p>
</div> </div>
</div> </div>
+14
View File
@@ -1256,6 +1256,20 @@ const handleWebSocketMessage = useCallback((data) => {
} }
break; break;
case 'info':
// Restore progress is displayed inline by BackupSection. Show a single
// confirmation once the operation has finished instead of warning on
// every intermediate progress message.
if (data.serverId === selectedServer?.id && data.message?.includes('Restoration completed successfully')) {
setAlertModal({
open: true,
title: 'Restore complete',
message: data.message,
type: 'success'
});
}
break;
case '2fa_setup_details': case '2fa_setup_details':
setTwoFactorData(data); setTwoFactorData(data);
setShow2FASetup(true); setShow2FASetup(true);