Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add backup type label (#34146)

Joshen Lim6fe0c164d2ea
diff --git a/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx b/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx
index 67e66b60f19..7b9de9b0863 100644
--- a/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx
+++ b/apps/studio/components/interfaces/Database/Backups/BackupItem.tsx
@@ -3,10 +3,11 @@ import { Download } from 'lucide-react'
import { useParams } from 'common'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
+import { InlineLink } from 'components/ui/InlineLink'
import { useBackupDownloadMutation } from 'data/database/backup-download-mutation'
import type { DatabaseBackup } from 'data/database/backups-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { Badge } from 'ui'
+import { Badge, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { TimestampInfo } from 'ui-patterns'
interface BackupItemProps {
@@ -58,28 +59,36 @@ const BackupItem = ({ index, isHealthy, backup, onSelectBackup }: BackupItemProp
>
Restore
</ButtonTooltip>
- {!backup.isPhysicalBackup && (
- <ButtonTooltip
- type="default"
- icon={<Download />}
- loading={isDownloading}
- disabled={!canTriggerScheduledBackups || isDownloading}
- onClick={() => {
- if (!projectRef) return console.error('Project ref is required')
- downloadBackup({ ref: projectRef, backup })
- }}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canTriggerScheduledBackups
- ? 'You need additional permissions to download backups'
- : undefined,
- },
- }}
- >
- Download
- </ButtonTooltip>
- )}
+ <ButtonTooltip
+ type="default"
+ icon={<Download />}
+ loading={isDownloading}
+ disabled={!canTriggerScheduledBackups || isDownloading || backup.isPhysicalBackup}
+ onClick={() => {
+ if (!projectRef) return console.error('Project ref is required')
+ downloadBackup({ ref: projectRef, backup })
+ }}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ className: backup.isPhysicalBackup ? 'w-64' : '',
+ text: backup.isPhysicalBackup ? (
+ <>
+ Physical backups cannot be downloaded through the dashboard. You can still
+ download it via pgdump by following our guide{' '}
+ <InlineLink href="https://supabase.com/docs/guides/troubleshooting/download-logical-backups">
+ here
+ </InlineLink>
+ .
+ </>
+ ) : !canTriggerScheduledBackups ? (
+ 'You need additional permissions to download backups'
+ ) : undefined,
+ },
+ }}
+ >
+ Download
+ </ButtonTooltip>
</div>
)
return <Badge variant="warning">Backup In Progress...</Badge>
@@ -91,12 +100,25 @@ const BackupItem = ({ index, isHealthy, backup, onSelectBackup }: BackupItemProp
index ? 'border-t border-default' : ''
}`}
>
- <TimestampInfo
- displayAs="utc"
- utcTimestamp={backup.inserted_at}
- labelFormat="DD MMM YYYY HH:mm:ss (ZZ)"
- className="text-left !text-sm font-mono tracking-tight"
- />
+ <div className="flex items-center gap-x-2">
+ <TimestampInfo
+ displayAs="utc"
+ utcTimestamp={backup.inserted_at}
+ labelFormat="DD MMM YYYY HH:mm:ss (ZZ)"
+ className="text-left !text-sm font-mono tracking-tight"
+ />
+ <Tooltip>
+ <TooltipTrigger>
+ <Badge variant="default">{backup.isPhysicalBackup ? 'Physical' : 'Logical'}</Badge>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ Learn more about backup types{' '}
+ <InlineLink href="https://supabase.com/blog/postgresql-physical-logical-backups">
+ here
+ </InlineLink>
+ </TooltipContent>
+ </Tooltip>
+ </div>
<div>{generateSideButtons(backup)}</div>
</div>
)
diff --git a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
index 5f4bf20491e..6cbae550a21 100644
--- a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
@@ -25,6 +25,7 @@ const RestoringState = () => {
const { data } = useDownloadableBackupQuery({ projectRef: ref })
const backups = data?.backups ?? []
+ const logicalBackups = backups.filter((b) => !b.isPhysicalBackup)
const { mutate: downloadBackup, isLoading: isDownloading } = useBackupDownloadMutation({
onSuccess: (res) => {
@@ -41,8 +42,9 @@ const RestoringState = () => {
const onClickDownloadBackup = () => {
if (!ref) return console.error('Project ref is required')
- if (backups.length === 0) return console.error('No available backups to download')
- downloadBackup({ ref, backup: backups[0] })
+ if (logicalBackups.length === 0) return console.error('No available backups to download')
+
+ downloadBackup({ ref, backup: logicalBackups[0] })
}
async function checkServer() {
@@ -125,16 +127,17 @@ const RestoringState = () => {
type="default"
icon={<Download />}
loading={isDownloading}
- disabled={backups.length === 0}
+ disabled={logicalBackups.length === 0}
tooltip={{
content: {
side: 'bottom',
- text: backups.length === 0 ? 'No available backups to download' : undefined,
+ text:
+ logicalBackups.length === 0 ? 'No available backups to download' : undefined,
},
}}
onClick={onClickDownloadBackup}
>
- Download backup
+ Download latest backup
</ButtonTooltip>
</div>
</>