Skip to content

Commit f256170

Browse files
d-bytebaseclaude
andauthored
docs: improve clarity and readability of upgrade documentation (#799)
* docs: improve clarity and readability of upgrade documentation - Reword upgrade process steps for better clarity and flow - Update backup/restore procedures with more descriptive language - Clarify that restoration requires using the previous Bytebase version - Simplify backup procedures by removing redundant options - Improve consistency in heading styles and terminology throughout 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * chore: update --------- Co-authored-by: Claude <[email protected]>
1 parent 5d44e03 commit f256170

File tree

1 file changed

+42
-84
lines changed

1 file changed

+42
-84
lines changed

mintlify/get-started/self-host/upgrade.mdx

Lines changed: 42 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -4,122 +4,80 @@ title: Upgrade
44

55
## Upgrade Process
66

7-
The following example demonstrates upgrading Bytebase using Docker. **Follow these steps in the exact order to ensure a safe upgrade:**
7+
This guide walks through upgrading Bytebase with Docker. **Complete each step sequentially to ensure a smooth and safe upgrade:**
88

9-
### Step 1: Stop and Remove the Current Container
9+
### Step 1: Stop and Remove the Existing Container
1010

11-
To prevent database corruption, ensure only one Bytebase instance accesses the metadata at a time:
11+
First, gracefully stop and remove your current Bytebase container. This prevents data corruption by ensuring no concurrent access to the metadata.
1212

13-
```text
14-
docker stop bytebase
15-
docker rm bytebase
16-
```
17-
18-
### Step 2: Create a Metadata Backup
13+
### Step 2: Back Up Your Metadata
1914

20-
🚨 **Critical:** Always create a backup of your metadata before upgrading. This backup is essential if you need to rollback to a previous version. See the "Back up Data" section below for detailed instructions.
15+
🚨 **Critical:** Before proceeding, create a complete backup of your metadata. This backup serves as your safety net for rolling back if needed. Refer to the "Back up and Restore" section below for comprehensive backup procedures.
2116

22-
### Step 3: Deploy the New Version
17+
### Step 3: Launch the Updated Version
2318

24-
Launch Bytebase with the updated version using the appropriate Docker run command for your setup.
19+
Start Bytebase with the new version using your existing Docker run command, updating only the image tag to the desired version.
2520

2621
<Warning>
27-
**Best Practice:** Always test the upgrade process in a staging environment before applying it to production.
22+
**Production Safety:** Validate your upgrade procedure in a staging environment before executing it in production.
2823
</Warning>
2924

30-
## Back up Data
31-
32-
### External PostgreSQL Metadata (Recommended)
33-
34-
If [`--pg`](/reference/command-line#--pg-string) is specified, the metadata will be stored in the specified external PostgreSQL database. Below shows how to back up and restore the Bytebase metadata, let's assume the metadata is stored in `metadb`.
35-
36-
#### Back up the metadata
37-
38-
```text
39-
pg_dump -h <<host>> -p <<port>> -U <<user>> -d metadb > metadb.sql
40-
```
41-
42-
#### Restore Option 1 - Restore to the same `metadb`
43-
44-
##### Step 1 - Restore metadata to a temporary db
45-
46-
Create a new db `metadb_new`:
47-
48-
```text
49-
psql -h <<host>> -p <<port>> -U <<user>> metadb -c "CREATE DATABASE metadb_new"
50-
```
51-
52-
Restore metadata to the new db:
53-
54-
```text
55-
psql -h <<host>> -p <<port>> -U <<user>> metadb_new < metadb.sql
56-
```
57-
58-
##### Step 2 - Swap the existing metadata db with the temporary db
25+
## Back up and Restore
5926

60-
<Tip>
27+
### External PostgreSQL (Recommended)
6128

62-
You need to first stop Bytebase otherwise its connection to the metadata db will prevent renaming the database.
29+
#### Creating a Backup
6330

64-
Also, you can not rename the connecting database so you need to connect to the PostgreSQL instance using a different database like `postgres`.
65-
66-
</Tip>
67-
68-
Rename existing `metadb` to `metadb_old`:
31+
Execute the following command to create a complete database clone:
6932

7033
```text
71-
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "ALTER DATABASE metadb RENAME TO metadb_old"
34+
psql -h <<host>> -p <<port>> -U <<user>> metadb -c "CREATE DATABASE metadb_backup WITH TEMPLATE metadb;"
7235
```
7336

74-
Rename `metadb_new` to the `metadb`, which will serve as the new metadata db:
37+
#### Restoring from Backup
7538

76-
```text
77-
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "ALTER DATABASE metadb_new RENAME TO metadb"
78-
```
39+
1. Stop your Bytebase instance completely.
7940

80-
##### Step 3 - Drop the old metadata db
41+
2. Preserve the current database by renaming it:
42+
43+
```text
44+
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "ALTER DATABASE metadb RENAME TO metadb_old"
45+
```
8146

82-
Restart Bytebase and verify the metadata is restored properly. Afterwards, you can drop the old database:
47+
3. Restore from your backup:
48+
49+
```text
50+
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "CREATE DATABASE metadb WITH TEMPLATE metadb_backup;"
51+
```
8352

84-
```text
85-
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "DROP DATABASE metadb_old"
86-
```
53+
4. Start Bytebase with the previous version (the version you were running before the failed upgrade).
8754

88-
#### Restore Option 2 - Restore to a different database `metadb2`
55+
5. After confirming successful restoration, remove temporary databases:
56+
57+
```text
58+
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "DROP DATABASE metadb_old"
59+
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "DROP DATABASE metadb_backup"
60+
```
8961

62+
### Embedded PostgreSQL
9063

91-
##### Step 1 - Restore metadata to `metadb2`
64+
#### Creating a Backup
9265

93-
Create a new db `metadb2`:
66+
Archive your entire data directory to preserve the embedded database:
9467

9568
```text
96-
psql -h <<host>> -p <<port>> -U <<user>> metadb -c "CREATE DATABASE metadb2"
69+
tar -czf bytebase-backup.tar.gz /path/to/data
9770
```
9871

99-
Restore metadata to the new db:
100-
101-
```text
102-
psql -h <<host>> -p <<port>> -U <<user>> metadb2 < metadb.sql
103-
```
72+
#### Restoring from Backup
10473

105-
##### Step 2 - Drop the old metadata db
74+
Follow these steps to restore your embedded PostgreSQL data:
10675

107-
Restart Bytebase and verify the metadata is restored properly. Afterwards, you can drop the old database:
76+
1. Stop your Bytebase instance completely
77+
2. Extract and replace the data directory from your backup:
10878

10979
```text
110-
psql -h <<host>> -p <<port>> -U <<user>> postgres -c "DROP DATABASE metadb"
80+
tar -xzf bytebase-backup.tar.gz -C /
11181
```
11282

113-
### Embedded PostgreSQL Metadata
114-
115-
If [External PostgreSQL](/get-started/self-host/external-postgres/) is not configured, then
116-
Bytebase will store the metadata under the [`--data`](/reference/command-line#--data-directory) directory.
117-
You can back up the `--data` directory or the `pgdata` subfolder.
118-
119-
<Note>
120-
121-
You should periodically back up the entire [`--data`](/reference/command-line#--data-directory) directory if any data is stored there.
122-
123-
If Bytebase is running and not in the [`--readonly`](/reference/command-line#--readonly) mode, and you want to take the backup, then the underlying data volume must support snapshot feature where the entire directory can take a snapshot at the same time, otherwise it may produce a corrupted backup bundle.
124-
125-
</Note>
83+
3. Start Bytebase with the previous version using the restored data directory

0 commit comments

Comments
 (0)