Skip to content
Local Development

本地恢复已下载的备份

Restore a backup of a remote database on a local instance to inspect and extract data

如果你的暂停项目已经超过了恢复时间限制,你可以从仪表板下载备份并将其恢复到本地开发环境。这对于检查和提取暂停项目中的数据可能会很有用。

🌐 If your paused project has exceeded its restoring time limit, you can download a backup from the dashboard and restore it to your local development environment. This might be useful for inspecting and extracting data from your paused project.

正在下载你的备份 #

🌐 Downloading your backup

首先,从仪表板下载你项目的备份文件,并确认它的备份镜像版本(以 PG: 前缀开头):

🌐 First, download your project's backup file from dashboard and identify its backup image version (following the PG: prefix):

Project Paused: 90 Days Remaining

正在恢复你的备份 #

🌐 Restoring your backup

对于 Postgres 版本 15.6.1.115,在本地启动 Postgres,db_cluster.backup 是你的备份文件路径。

🌐 Given Postgres version 15.6.1.115, start Postgres locally with db_cluster.backup being the path to your backup file.

1
supabase init
2
echo '15.6.1.115' > supabase/.temp/postgres-version
3
supabase db start --from-backup db_cluster.backup

请注意,支持本地恢复的最早 Supabase Postgres 版本是 15.1.0.55。如果你的托管项目运行的是更早的版本,在恢复时很可能会遇到错误。在提交任何支持工单之前,确保你已经附上了来自 supabase_db_* Docker 容器的错误日志。

🌐 Note that the earliest Supabase Postgres version that supports a local restore is 15.1.0.55. If your hosted project was running on earlier versions, you will likely run into errors during restore. Before submitting any support ticket, make sure you have attached the error logs from supabase_db_* docker container.

一旦你的本地数据库成功启动,你就可以用 psql 连接,确认所有数据都已恢复。

🌐 Once your local database starts up successfully, you can connect using psql to verify that all your data is restored.

1
psql 'postgresql://postgres:postgres@localhost:54322/postgres'

如果你想在恢复的数据库中一起使用其他服务,比如 Auth、Storage 和 Studio 仪表板,请重启本地开发环境。

🌐 If you want to use other services like Auth, Storage, and Studio dashboard together with your restored database, restart the local development stack.

1
supabase stop
2
supabase start

用 Supabase CLI 启动的 Postgres 数据库还不能用于生产环境,最好别在本地开发以外的地方使用。

🌐 A Postgres database started with Supabase CLI is not production ready and should not be used outside of local development.