import { useQuery } from '@tanstack/react-query'; import { Notice } from '#/components/atoms/notice.jsx'; import { Panel } from '#/components/atoms/panel.jsx'; import { Skeleton } from '#/components/atoms/skeleton.jsx'; import { Section } from '#/components/molecules/section.jsx'; import { BackupKeyCard } from '#/components/organisms/backup-key-card.jsx'; import { BackupRunsCard } from '#/components/organisms/backup-runs-card.jsx'; import { BackupSettingsCard } from '#/components/organisms/backup-settings-card.jsx'; import { RepoDownloadCard } from '#/components/organisms/repo-download-card.jsx'; import { get } from '#/lib/api.js'; import { queryKeys } from '#/lib/query.js'; export function BackupsPage({ data }) { const { data: backups, error } = useQuery({ queryKey: queryKeys.backups, queryFn: () => get('/backups'), // While a run is live its counters change server-side every few seconds; // poll so the history row ticks instead of sitting at zero. refetchInterval: (query) => query.state.data?.runs?.some((run) => run.status === 'running') ? 3000 : false, }); if (error) { return {error.message}; } if (!backups) { return (
); } const download = ; if (!backups.available) { return (
Automatic backups need a backup target configured on the server. On Node or Deno, set{' '} PDS_BACKUP_DIR{' '} or S3 credentials in the environment; on Cloudflare, bind a{' '} BACKUPS R2 bucket. Until then, you can still download a copy of your repository here.
{download}
); } return (
{download}
); }