Skip to content

Commit c21ab53

Browse files
authored
add full backup tool in 1.3.x 2.0.x master (#640)
* add full backup tool in 1.3.x 2.0.x master * add backup tool in dev-1.3
1 parent c5ff422 commit c21ab53

16 files changed

Lines changed: 1056 additions & 0 deletions

File tree

src/.vuepress/sidebar/V1.3.x/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export const enSidebar = {
159159
{ text: 'TsFile Import Export(V1.3.0/1/2)', link: 'TsFile-Import-Export-Tool' },
160160
{ text: 'Data Import(V1.3.3)', link: 'Data-Import-Tool' },
161161
{ text: 'Data Export(V1.3.3)', link: 'Data-Export-Tool' },
162+
{ text: 'Full Backup Tool(V1.3.2)', link: 'Backup-Tool' },
162163
{ text: 'Health Check Tool(V1.3.2)', link: 'Health-Check-Tool' },
163164
],
164165
},

src/.vuepress/sidebar/V1.3.x/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export const zhSidebar = {
146146
{ text: 'TsFile导入导出(V1.3.0/1/2)', link: 'TsFile-Import-Export-Tool' },
147147
{ text: '数据导入(V1.3.3)', link: 'Data-Import-Tool' },
148148
{ text: '数据导出(V1.3.3)', link: 'Data-Export-Tool' },
149+
{ text: '全量备份工具(V1.3.2)', link: 'Backup-Tool' },
149150
{ text: '健康检查工具(V1.3.2)', link: 'Health-Check-Tool' },
150151
],
151152
},

src/.vuepress/sidebar/V2.0.x/en-Tree.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export const enSidebar = {
140140
{ text: 'Cluster Management Tool', link: 'Maintenance-Tool_apache' },
141141
{ text: 'Data Import', link: 'Data-Import-Tool' },
142142
{ text: 'Data Export', link: 'Data-Export-Tool' },
143+
{ text: 'Full Backup Tool', link: 'Backup-Tool' },
143144
{ text: 'Health Check Tool', link: 'Health-Check-Tool' },
144145
],
145146
},

src/.vuepress/sidebar/V2.0.x/zh-Tree.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export const zhSidebar = {
127127
{ text: '集群管理工具', link: 'Maintenance-Tool_apache' },
128128
{ text: '数据导入', link: 'Data-Import-Tool' },
129129
{ text: '数据导出', link: 'Data-Export-Tool' },
130+
{ text: '全量备份工具', link: 'Backup-Tool' },
130131
{ text: '健康检查工具', link: 'Health-Check-Tool' },
131132
],
132133
},

src/.vuepress/sidebar_timecho/V1.3.x/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export const enSidebar = {
173173
{ text: 'TsFile Import Export(V1.3.0/1/2)', link: 'TsFile-Import-Export-Tool' },
174174
{ text: 'Data Import(V1.3.3)', link: 'Data-Import-Tool' },
175175
{ text: 'Data Export(V1.3.3)', link: 'Data-Export-Tool' },
176+
{ text: 'Full Backup Tool(V1.3.2)', link: 'Backup-Tool' },
176177
{ text: 'Health Check Tool(V1.3.2)', link: 'Health-Check-Tool' },
177178
],
178179
},

src/.vuepress/sidebar_timecho/V1.3.x/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export const zhSidebar = {
156156
{ text: 'TsFile导入导出(V1.3.0/1/2)', link: 'TsFile-Import-Export-Tool' },
157157
{ text: '数据导入(V1.3.3)', link: 'Data-Import-Tool' },
158158
{ text: '数据导出(V1.3.3)', link: 'Data-Export-Tool' },
159+
{ text: '全量备份工具(V1.3.2)', link: 'Backup-Tool' },
159160
{ text: '健康检查工具(V1.3.2)', link: 'Health-Check-Tool' },
160161
],
161162
},

src/.vuepress/sidebar_timecho/V2.0.x/en-Tree.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export const enSidebar = {
154154
{ text: 'Cluster Management Tool', link: 'Maintenance-Tool_timecho' },
155155
{ text: 'Data Import', link: 'Data-Import-Tool' },
156156
{ text: 'Data Export', link: 'Data-Export-Tool' },
157+
{ text: 'Full Backup Tool', link: 'Backup-Tool' },
157158
{ text: 'Health Check Tool', link: 'Health-Check-Tool' },
158159
],
159160
},

src/.vuepress/sidebar_timecho/V2.0.x/zh-Tree.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export const zhSidebar = {
137137
{ text: '集群管理工具', link: 'Maintenance-Tool_timecho' },
138138
{ text: '数据导入', link: 'Data-Import-Tool' },
139139
{ text: '数据导出', link: 'Data-Export-Tool' },
140+
{ text: '全量备份工具', link: 'Backup-Tool' },
140141
{ text: '健康检查工具', link: 'Health-Check-Tool' },
141142
],
142143
},
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# Backup Tool
23+
24+
## 1. Overview
25+
26+
The IoTDB Full Backup Tool is designed to create a full backup of a single IoTDB node’s data via hard links to a specified local directory. The backup can then be directly started and joined to the original cluster. The tool offers two modes: **Quick Mirror Mode** and **Manual Backup Path Mode**.
27+
28+
> **Notes**:
29+
>
30+
> * **Stop the IoTDB service before starting the backup**.
31+
> * The script runs in the background by default, and logs are saved to log files during execution.
32+
33+
34+
## 2. Backup Modes
35+
36+
### 2.1 Mode 1: Quick Mirror Mode
37+
38+
#### Usage
39+
40+
```bash
41+
backup.sh/backup.bat -quick -node xxx
42+
# Optional values for xxx are shown in the following examples
43+
44+
backup.sh/backup.bat -quick -node
45+
# Back up all nodes to the default path
46+
47+
backup.sh/backup.bat -quick -node all
48+
# Back up all nodes to the default path
49+
50+
backup.sh/backup.bat -quick -node confignode
51+
# Back up only the ConfigNode to the default path
52+
53+
backup.sh/backup.bat -quick -node datanode
54+
# Back up only the DataNode to the default path
55+
```
56+
57+
#### Parameter Descriptions
58+
59+
| **Parameter** | **Description** | **Required** |
60+
| ----------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---------------------- |
61+
| `-quick` | Enables Quick Mirror Mode. | No |
62+
| `-node` | Specifies the node type to back up. Options: `all`, `datanode`, or `confignode`. Default: `all`. <br>`all`: Back up both DataNode and ConfigNode. <br>`datanode`: Back up only the DataNode. <br>`confignode`: Back up only the ConfigNode. | No |
63+
64+
**Process Details**:
65+
66+
1. Check if the `_backup` folder already exists in the current IoTDB directory or paths specified in the configuration file. If it exists, the tool exits with the error: `The backup folder already exists`.
67+
> When the backup folder already exists, you can try the following solutions:
68+
> * Delete the existing _backup folder and retry the backup.
69+
> * Modify the backup path to avoid conflicts.
70+
71+
2. Create hard links from the original `dn_data_dirs` paths to the corresponding `_backup` paths.
72+
* Example: If `dn_data_dirs=/data/iotdb/data/datanode/data`, the backup data will be stored in `/data/iotdb/data/datanode/data_backup`.
73+
3. Copy other files from the IoTDB directory (e.g., `/data/iotdb`) to the `_backup` path (e.g., `/data/iotdb_backup`).
74+
75+
76+
### 2.2 Mode 2: Manual Backup Path Mode
77+
78+
#### Usage
79+
80+
```bash
81+
backup.sh -node xxx -targetdir xxx -targetdatadir xxx -targetwaldir xxx
82+
```
83+
84+
#### Parameter Descriptions
85+
86+
| **Parameter** | **Description** | **Required** |
87+
| ----------------------- | -------------------------------------------------------------------------------------------- | ---------------------- |
88+
| `-node` | Node type to back up (`all`, `datanode`, or `confignode`). Default: `all`. | No |
89+
| `-targetdir` | Target directory for backing up the IoTDB folder. | **Yes** |
90+
| `-targetdatadir` | Target path for `dn_data_dirs` files. Default: `targetdir/data/datanode/data`. | No |
91+
| `-targetwaldir` | Target path for `dn_wal_dirs` files. Default: `targetdir/data/datanode/wal`. | No |
92+
93+
**Process Details**:
94+
95+
1. The `-targetdir` parameter is mandatory. If missing, the tool exits with the error: `-targetdir cannot be empty. The backup folder must be specified`.
96+
2. Validate consistency between configuration paths (`dn_data_dirs`, `dn_wal_dirs`) and parameters (`-targetdatadir`, `-targetwaldir`):
97+
98+
* If `-targetdatadir` or `-targetwaldir` is a single path, it is considered consistent.
99+
* If the number of source paths (from configuration) does not match the target paths, the tool exits with the error: `-targetdatadir parameter exception: the number of original paths does not match the specified paths`.
100+
3. Check if `-targetdatadir` paths are on the same disk as the original paths:
101+
102+
* **Same disk**: Attempt to create hard links. If hard links fail, copy files instead.
103+
* **Different disk**: Copy files directly.
104+
4. Path Matching Rules
105+
106+
* **Many-to-One**: Multiple source paths can be backed up to a single target path.
107+
* **One-to-One**: A single source path can be backed up to a single target path.
108+
* **Many-to-Many**: Multiple source paths can be backed up to multiple target paths, but the pattern must match.
109+
110+
#### Examples
111+
112+
| **Configuration Paths** | **`-targetdatadir` Paths** | **Result** |
113+
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
114+
| `/data/iotdb/data/datanode/data` | `/data/iotdb_backup/data/datanode/data` |**Consistent** |
115+
| `/data/iotdb/data/datanode/data` | `/data/iotdb_backup/data/datanode/data1,/data/iotdb_backup/data/datanode/data2` | **Inconsistent** |
116+
| `/data/iotdb/data/datanode/data1,/data/iotdb/data/datanode/data2` | `/data/iotdb_backup/data/datanode/data` | **Consistent** |
117+
| `/data/iotdb/data/datanode/data1,/data/iotdb/data/datanode/data2` | `/data/iotdb_backup/data/datanode/data3,/data/iotdb_backup/data/datanode/data4` | **Consistent** |
118+
| `/data/iotdb/data/datanode/data1,/data/iotdb/data/datanode/data2;/data/iotdb/data/datanode/data3` | `/data/iotdb_backup/data/datanode/data` | **Consistent** |
119+
| `/data/iotdb/data/datanode/data1,/data/iotdb/data/datanode/data2;/data/iotdb/data/datanode/data3` | `/data/iotdb_backup/data/datanode/data1;/data/iotdb_backup/data/datanode/data1` | **Consistent** |
120+
| `/data/iotdb/data/datanode/data1,/data/iotdb/data/datanode/data2;/data/iotdb/data/datanode/data3` | `/data/iotdb_backup/data/datanode/data1,/data/iotdb_backup/data/datanode/data3;/data/iotdb_backup/data/datanode/data` | **Consistent** |
121+
| `/data/iotdb/data/datanode/data1,/data/iotdb/data/datanode/data2;/data/iotdb/data/datanode/data3` | `/data/iotdb_backup/data/datanode/data1,/data/iotdb_backup/data/datanode/data3;/data/iotdb_backup/data/datanode/data1,/data/iotdb_backup/data/datanode/data4` | **Inconsistent** |
122+
123+
#### Path Matching Rules Summary
124+
125+
* **Paths separated by `;` only**:
126+
* `-targetdatadir` can be a single path (no `;` or `,`).
127+
* `-targetdatadir` can also use `;` to split paths, but the count must match the source paths.
128+
* **Paths separated by `,` only**:
129+
* `-targetdatadir` can be a single path (no `;` or `,`).
130+
* `-targetdatadir` can also use `,` to split paths, but the count must match the source paths.
131+
* **Paths with both `;` and `,`**:
132+
* `-targetdatadir` can be a single path (no `;` or `,`).
133+
* Split paths first by `;`, then by `,`. The number of paths at each level must match.
134+
135+
> **Note**: The `dn_wal_dirs` parameter (for WAL paths) follows the same rules as `dn_data_dirs`.

0 commit comments

Comments
 (0)