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 [loading, setLoading] = useState(true);
const [creating, setCreating] = useState(false);
const [restoring, setRestoring] = useState(false);
const [restoreStatus, setRestoreStatus] = useState('');
const [restoreBackupId, setRestoreBackupId] = useState(null);
const [backupName, setBackupName] = useState('');
const [showCreateForm, setShowCreateForm] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
@@ -53,30 +56,30 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
}
} else if (data.type === 'backup_deleted') {
setBackups(prev => prev.filter(b => b.id !== data.backupId));
} else if (data.type === 'info' && data.message.includes('Restoration')) {
// Optional: handle restoration progress info messages if needed
} else if (data.type === 'info' && data.backupId === restoreBackupId) {
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) {
console.error("Error processing backup message:", e);
}
}
}, [lastMessage, serverId]);
const handleCreateBackup = () => {
if (creating) return;
setCreating(true);
sendMessage({
type: 'create_backup',
serverId: serverId,
name: backupName || undefined
});
setBackupName('');
setShowCreateForm(false);
};
}, [lastMessage, serverId, restoreBackupId]);
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.")) {
setRestoreBackupId(backupId);
setRestoring(true);
setRestoreStatus('Preparing restore…');
sendMessage({
type: 'restore_backup',
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) => {
switch (status) {
case 'Completed': return colors.green;
case 'Failed': return colors.red;
case 'Unavailable': return colors.yellow;
case 'In Progress': return colors.yellow;
default: return colors.foreground;
}
@@ -114,7 +130,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
};
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()))
);
@@ -126,7 +142,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<Database className="w-6 h-6 text-primary" />
Backups & Snapshots
</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 className="flex items-center gap-3">
@@ -149,7 +165,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton
variant="primary"
onClick={() => setShowCreateForm(true)}
disabled={creating}
disabled={creating || restoring}
className="whitespace-nowrap shadow-lg shadow-primary/20"
>
<Plus className="w-4 h-4" />
@@ -158,6 +174,18 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
</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 && (
<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">
@@ -177,7 +205,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton onClick={() => setShowCreateForm(false)} variant="secondary" className="flex-1 sm:flex-none">
Cancel
</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 ? 'Creating...' : 'Start Backup'}
</ActionButton>
@@ -194,7 +222,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<DashboardEmptyState
icon={Database}
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={
<ActionButton variant="primary" onClick={() => setShowCreateForm(true)}>
Create your first backup
@@ -213,11 +241,12 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<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 === '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'
}`}>
{backup.status === 'In Progress' ? (
<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" />
) : (
<ShieldCheck className="w-6 h-6 text-primary" />
@@ -248,6 +277,9 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
{backup.status.toUpperCase()}
</span>
</div>
{backup.unavailableReason && (
<p className="mt-2 text-xs text-red-400">{backup.unavailableReason}</p>
)}
</div>
</div>
@@ -256,7 +288,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton
variant="secondary"
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"
>
<RotateCcw className="w-4 h-4" />
@@ -268,7 +300,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<ActionButton
variant="danger"
onClick={() => handleDelete(backup.id)}
disabled={backup.status === 'In Progress'}
disabled={backup.status === 'In Progress' || restoring}
className="px-3 h-10 min-h-0"
>
<Trash2 className="w-4 h-4" />
@@ -293,9 +325,7 @@ const BackupSection = ({ serverId, sendMessage, lastMessage }) => {
<div>
<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">
Manual backups are kept indefinitely until deleted. Automated daily snapshots are retained for 7 days.
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.
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.
</p>
</div>
</div>
+14
View File
@@ -1255,6 +1255,20 @@ const handleWebSocketMessage = useCallback((data) => {
});
}
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':
setTwoFactorData(data);