'use client' import { useCallback, useState } from 'react' import Link from 'next/link' import { useFlowRun } from '@/hooks/useFlowRun' import StreamingTerminal from '@/components/StreamingTerminal' import ConfirmDialog from '@/components/ConfirmDialog' import type { BackupFile } from '../page' function formatSize(bytes: number): string { if (bytes === 0) return '—' if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)} KB` return `${(bytes / (1024 * 1024)).toFixed(1)} MB` } type Props = { backups: BackupFile[] listError: string | null } export default function DatabaseBackupsSection({ backups, listError }: Props) { const [pending, setPending] = useState(false) const [completedFlowRunId, setCompletedFlowRunId] = useState(null) const handleComplete = useCallback((flowRunId: string) => { setCompletedFlowRunId(flowRunId) }, []) const flowRun = useFlowRun(handleComplete) const handleConfirm = useCallback(() => { setPending(false) setCompletedFlowRunId(null) flowRun.startFlow('backup_ops_db', false) }, [flowRun]) const handleReset = useCallback(() => { flowRun.reset() setCompletedFlowRunId(null) }, [flowRun]) return (

Database backups

flow: backup_ops_db

Backs up the ops_dashboard database using{' '} pg_dump. Dumps are stored in{' '} /srv/ops/backups/ and retained for 30 days. For automated daily backups, enable the systemd timer:{' '} deploy/ops-agent/ops-db-backup.timer.

  1. 1. pg_dump ops_dashboard → /srv/ops/backups/ops_db_YYYYMMDD_HHMM.dump
  2. 2. cleanup: delete backup files older than 30 days
{flowRun.status !== 'idle' && flowRun.status !== 'running' && ( )}
{flowRun.status !== 'idle' && (
Output {completedFlowRunId && ( View in audit log → )}
{flowRun.status === 'done' && (

Reload this page to see the updated backup list.

)}
)}

Existing backups

{listError && (
Could not list backups: {listError}
)} {!listError && backups.length === 0 && (
No backups found in /srv/ops/backups/
)} {!listError && backups.length > 0 && (
{backups.map((b, i) => ( ))}
Timestamp File Size
{b.label} {b.name} {formatSize(b.sizeBytes)}
)}

Backups older than 30 days are removed automatically by the cleanup step.

setPending(false)} />
) }