Skip to content

Commit dfa6976

Browse files
authored
chore: dump command, guide to restore data (#354)
* dump command * text
1 parent d27556f commit dfa6976

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed

guides/migrate-shared-postgres.mdx

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ description: Migrate Postgres data to shuttle.dev
44
icon: dove
55
---
66

7-
This guide shows how to restore schemas and table data in a Shuttle database.
8-
Dumping data is a planned feature.
7+
This guide shows how to dump schemas and table data from a [Shared Postgres](/resources/shuttle-shared-db) database, and restore a dump.
98

109
If you encounter issues, feel free to [contact us](/support/support) for help.
1110

@@ -23,38 +22,7 @@ sudo apt install postgresql-client
2322
Shuttle Postgres databases run Postgres version 16, so `psql` versions older than 16 might not work.
2423
</Warning>
2524

26-
{/*
27-
## 1. Deploy and provision Shared Postgres on shuttle.dev
28-
29-
Follow [Platform Migration](/platform-update/migration) to deploy your app to **shuttle.dev**, including the provisioning of the database resource.
30-
31-
If you want the restore step to restore both the schema and data, you can temporarily disable migration logic in your app during this phase.
32-
33-
## 2. Upgrade container on shuttle.rs and Shuttle CLI
34-
35-
To use the dump command, your deployer and CLI need to be v0.52.0 or higher.
36-
37-
Upgrade the CLI by following the [upgrading guide](/guides/upgrade).
38-
39-
Restarting the project will upgrade the deployer to the latest version:
40-
41-
```sh
42-
cargo shuttle project restart
43-
```
44-
45-
## 3. (Optional) Stop running service on shuttle.rs
46-
47-
If your app is frequently writing to the tables, and you don't want data to go missing after the migration, it is recommended to stop the current deployment while you perform the database maintenance.
48-
49-
```sh
50-
cargo shuttle stop
51-
```
52-
53-
<Info>
54-
If you for any reason need to cancel the migration and start the service, do so by deploying again.
55-
</Info>
56-
57-
## 4. Dump data from shuttle.rs
25+
## Dump database to SQL file
5826

5927
Since the Shared Postgres cluster has strict permissions, running `pg_dump` against your connection string is not possible.
6028
Instead, you can use the `resource dump` command that runs `pg_dump` with `--no-owner --no-privileges` for you.
@@ -67,16 +35,15 @@ The command writes a dump in SQL format to stdout, so you can use it to write to
6735

6836
```sh
6937
# dump database into /tmp/dump.sql
70-
cargo shuttle resource dump database::shared::postgres > /tmp/dump.sql
38+
shuttle resource dump database::shared::postgres > /tmp/dump.sql
7139
```
7240

7341
<Note>
74-
The max size for the dump is 50 MB. If you get errors about request limits, reach out to us.
42+
If you get errors about request limits or timeouts, reach out to us for support.
7543
</Note>
7644

7745
You can inspect the file and edit it to your liking.
7846
If you already let your schema migrations run in the new db, you could for instance remove the `CREATE TABLE`, `ALTER TABLE` etc, and only keep the table data `COPY` statements and so on.
79-
*/}
8047

8148
## Restore data from a SQL file
8249

0 commit comments

Comments
 (0)