Skip to content

Commit 5dca800

Browse files
authored
Merge pull request #206 from heywalter/update-ops
Add backup and restore procedures for TapData
2 parents 9938772 + 37e276b commit 5dca800

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

.github/actions/spelling/allow.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,3 +772,8 @@ SYSTABLES
772772
tls
773773
tlsssl
774774
truststore
775+
czf
776+
mongodump
777+
mongorestore
778+
OBJEXIST
779+

docs/platform-ops/operation.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,69 @@ Subsystem:
6161

6262

6363

64+
## How to Back Up and Restore TapData
65+
66+
While TapData is running, critical data such as task configurations and shared cache are stored in MongoDB. For safe upgrades or migrations, use the [MongoDB Database Tools](https://www.mongodb.com/docs/database-tools/mongodump/) to back up the metadata database and (optionally) the TapData work directory, then restore them when needed.
67+
68+
69+
**Backup**
70+
71+
1. Preparation
72+
73+
Log in to the server hosting TapData, go to the installation directory, and stop the service. In an HA deployment, run this on each node one by one.
74+
```bash
75+
./tapdata stop -f
76+
```
77+
78+
2. Back up the metadata database using the following command format.
79+
80+
```bash
81+
mongodump --uri "mongodb://<username>:<password>@<mongodb_host>:<mongodb_port>/<database_name>?authSource=admin" --gzip --excludeCollection="collection_name" -o /backup/tapdata_db_$(date +%F)
82+
```
83+
- `<username>`, `<password>`: Username and password for the MongoDB instance.
84+
- `<mongodb_host>`, `<mongodb_port>`: MongoDB host and port (default: 27017).
85+
- `<database_name>`: Database name (default: tapdata; use your actual name if customized).
86+
- `--gzip`: Compresses backup files to reduce backup size.
87+
- `--excludeCollection="collection_name"`: Excludes specific collections from the backup (for example, system logs) to reduce backup time and storage usage. You can specify this option multiple times. Recommended settings: `--excludeCollection="AgentMeasurementV2" --excludeCollection="AlarmInfo" --excludeCollection="ApiCall" --excludeCollection="fs.files" --excludeCollection="fs.chunks" --excludeCollection="Message" --excludeCollection="monitoringLogs" --excludeCollection="InspectDetails" --excludeCollection="DDlTaskHistories" --excludeCollection="Logs"`
88+
89+
3. (Optional) For a full backup (for example, host-level migration), also back up the TapData work directory:
90+
```bash
91+
# Replace <tapdata_work_dir> with the actual work directory
92+
tar -czf /backup/tapdata_work_$(date +%F).tar.gz <tapdata_work_dir>
93+
```
94+
4. Start the service. In an HA deployment, run this on each node one by one.
95+
```bash
96+
# Replace <tapdata_work_dir> with the actual work directory
97+
./tapdata start --workDir <tapdata_work_dir>
98+
```
99+
100+
**Restore / Rollback**
101+
102+
1. Stop the service. In an HA deployment, run this on each node one by one.
103+
```bash
104+
./tapdata stop -f
105+
```
106+
107+
2. Import the metadata using `mongorestore`. If the target database already contains data, clean it up or rename it first to avoid conflicts.
108+
```bash
109+
mongorestore --uri "mongodb://<username>:<password>@<mongodb_host>:<mongodb_port>/<database_name>?authSource=admin" <backup_dir>/<database_name>
110+
```
111+
- `<username>`, `<password>`: Username and password for the MongoDB instance.
112+
- `<mongodb_host>`, `<mongodb_port>`: MongoDB host and port (default: 27017).
113+
- `<database_name>`: Database name (default: tapdata; use your actual name if customized).
114+
- `<backup_dir>`: Directory that contains the backup files (the output directory specified by `mongodump -o`).
115+
116+
3. Start the service. In an HA deployment, run this on each node one by one.
117+
```bash
118+
# Replace <tapdata_work_dir> with the actual work directory
119+
./tapdata start --workDir <tapdata_work_dir>
120+
```
121+
122+
:::tip
123+
For full host migrations, restore the TapData work directory to the new server before starting the service.
124+
:::
125+
126+
64127
## <span id="release330-upgrade">How to Perform a Rolling Upgrade?</span>
65128

66129
Starting with version 3.3.0, TapData supports rolling upgrades. Compared to the standard downtime upgrade, it helps shorten the upgrade window and further reduce business impact. The specific steps are as follows:

0 commit comments

Comments
 (0)