mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
with PITR enabled scheduled backups copy states incorrect information that might (and already have) confuse the customers The backups are still taken and the WAL is archived. There's just no point exposing regular backups when the customer is paying for a pretty expensive add-on, might as well point them at it
152 lines
5.0 KiB
TypeScript
152 lines
5.0 KiB
TypeScript
import { createFileRoute } from '@tanstack/react-router'
|
||
import { useParams } from 'common'
|
||
import { DatabaseBackupIcon, InfoIcon } from 'lucide-react'
|
||
import { Admonition } from 'ui-patterns/Admonition'
|
||
import { PageContainer } from 'ui-patterns/PageContainer'
|
||
import {
|
||
PageHeader,
|
||
PageHeaderMeta,
|
||
PageHeaderNavigationTabs,
|
||
PageHeaderSummary,
|
||
PageHeaderTitle,
|
||
} from 'ui-patterns/PageHeader'
|
||
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
|
||
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
|
||
|
||
import { BackupsList } from '@/components/interfaces/Database/Backups/BackupsList'
|
||
import DatabaseBackupsNav from '@/components/interfaces/Database/Backups/DatabaseBackupsNav'
|
||
import { AlertError } from '@/components/ui/AlertError'
|
||
import { DocsButton } from '@/components/ui/DocsButton'
|
||
import { HighAvailabilityDisabledEmptyState } from '@/components/ui/HighAvailability/HighAvailabilityDisabledEmptyState'
|
||
import InformationBox from '@/components/ui/InformationBox'
|
||
import { NoPermission } from '@/components/ui/NoPermission'
|
||
import { useBackupsQuery } from '@/data/database/backups-query'
|
||
import { FGA_PERMISSIONS, useAsyncCheckPermissionsV2 } from '@/hooks/misc/useCheckPermissionsV2'
|
||
import {
|
||
useIsHighAvailability,
|
||
useIsOrioleDbInAws,
|
||
useOrioleDbReleaseStage,
|
||
} from '@/hooks/misc/useSelectedProject'
|
||
import { DOCS_URL } from '@/lib/constants'
|
||
|
||
export const Route = createFileRoute('/project/$ref/database/backups/scheduled')({
|
||
component: DatabaseScheduledBackups,
|
||
staticData: {
|
||
databaseLayoutTitle: 'Backups',
|
||
},
|
||
})
|
||
|
||
function DatabaseScheduledBackups() {
|
||
return (
|
||
<>
|
||
<PageHeader>
|
||
<PageHeaderMeta>
|
||
<PageHeaderSummary>
|
||
<PageHeaderTitle>Database Backups</PageHeaderTitle>
|
||
</PageHeaderSummary>
|
||
</PageHeaderMeta>
|
||
<PageHeaderNavigationTabs>
|
||
<DatabaseBackupsNav active="scheduled" />
|
||
</PageHeaderNavigationTabs>
|
||
</PageHeader>
|
||
<PageContainer>
|
||
<PageSection>
|
||
<PageSectionContent>
|
||
<ScheduledBackups />
|
||
</PageSectionContent>
|
||
</PageSection>
|
||
</PageContainer>
|
||
</>
|
||
)
|
||
}
|
||
|
||
const ScheduledBackups = () => {
|
||
const { ref: projectRef } = useParams()
|
||
|
||
const {
|
||
data: backups,
|
||
error,
|
||
isPending: isLoading,
|
||
isError,
|
||
isSuccess,
|
||
} = useBackupsQuery({ projectRef })
|
||
|
||
const isHighAvailability = useIsHighAvailability()
|
||
const isOrioleDbInAws = useIsOrioleDbInAws()
|
||
const orioleDbReleaseStage = useOrioleDbReleaseStage()
|
||
const isPitrEnabled = backups?.pitr_enabled
|
||
|
||
const { can: canReadScheduledBackups, isSuccess: isPermissionsLoaded } =
|
||
useAsyncCheckPermissionsV2(FGA_PERMISSIONS.PROJECT.BACKUPS_READ)
|
||
|
||
if (isOrioleDbInAws && orioleDbReleaseStage === 'alpha') {
|
||
return (
|
||
<Admonition
|
||
type="default"
|
||
title="Database backups are not available for OrioleDB"
|
||
description={`OrioleDB is currently in public ${orioleDbReleaseStage} and projects created are strictly ephemeral with no database backups`}
|
||
>
|
||
<DocsButton abbrev={false} className="mt-2" href={DOCS_URL} />
|
||
</Admonition>
|
||
)
|
||
}
|
||
|
||
if (isHighAvailability) {
|
||
return (
|
||
<HighAvailabilityDisabledEmptyState
|
||
icon={DatabaseBackupIcon}
|
||
title="Scheduled backups unavailable on High Availability projects"
|
||
description="We're working to bring scheduled backups to High Availability projects. Contact support if this is blocking your work."
|
||
className="max-w-none mx-0"
|
||
/>
|
||
)
|
||
}
|
||
|
||
return (
|
||
<div className="flex flex-col gap-y-4">
|
||
{isLoading && <GenericSkeletonLoader />}
|
||
|
||
{isError && <AlertError error={error} subject="Failed to retrieve scheduled backups" />}
|
||
|
||
{isSuccess && (
|
||
<>
|
||
{!isPitrEnabled && (
|
||
<p className="text-sm text-foreground-light">
|
||
Projects are backed up daily around midnight of your project’s region and can be
|
||
restored at any time.
|
||
</p>
|
||
)}
|
||
|
||
{isPitrEnabled && (
|
||
<InformationBox
|
||
hideCollapse
|
||
defaultVisibility
|
||
icon={<InfoIcon strokeWidth={2} />}
|
||
title="Point-In-Time-Recovery (PITR) enabled"
|
||
description={
|
||
<div>
|
||
Your project uses PITR. Backups are still taken daily, with WAL continuously
|
||
archived on top of them, so you can restore to a point between the earliest and
|
||
latest recovery points for your selected PITR retention period.{' '}
|
||
<a
|
||
className="text-primary transition-colors hover:text-primary-hover"
|
||
href={`${DOCS_URL}/guides/platform/backups`}
|
||
>
|
||
Learn more
|
||
</a>
|
||
</div>
|
||
}
|
||
/>
|
||
)}
|
||
|
||
{isPermissionsLoaded && !canReadScheduledBackups ? (
|
||
<NoPermission resourceText="view scheduled backups" />
|
||
) : (
|
||
<BackupsList />
|
||
)}
|
||
</>
|
||
)}
|
||
</div>
|
||
)
|
||
}
|