Skip to content

Commit cdeb4c7

Browse files
committed
add export import snapshot
1 parent 5d15c73 commit cdeb4c7

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: export import snapshot
3+
weight: 4
4+
---
5+
`starcoin_db_exporter` command can export and offline import net main, barnard, halley, proxima snapshot
6+
offline import snapshot also can use import_snapshot.sh
7+
8+
<!--more-->
9+
10+
## Usage
11+
### export snapshot
12+
use `starcoin_db_exporter`
13+
run cmd
14+
```shell
15+
USAGE:
16+
starcoin_db_exporter export-snapshot [OPTIONS] --db-path <db-path> --net <net> --output <output>
17+
18+
FLAGS:
19+
-h, --help Prints help information
20+
-V, --version Prints version information
21+
22+
OPTIONS:
23+
-i, --db-path <db-path> starcoin node db path. like ~/.starcoin/main
24+
-t, --increment <increment> enable increment export snapshot
25+
-n, --net <net> Chain Network, like main, proxima
26+
-o, --output <output> output dir, like ~/, manifest.csv will write in output dir
27+
```
28+
the output snapshot data file is in dir ~/snapshot, the export snapshot cost 1hour-2hour()
29+
increment export snapshot
30+
```shell
31+
./starcoin_db_exporter export-snapshot -i ~/.starcoin/main -n main -o ~/snapshot -t true
32+
USAGE:
33+
starcoin_db_exporter export-snapshot [OPTIONS] --db-path <db-path> --net <net> --output <output>
34+
35+
FLAGS:
36+
-h, --help Prints help information
37+
-V, --version Prints version information
38+
39+
OPTIONS:
40+
-i, --db-path <db-path> starcoin node db path. like ~/.starcoin/main
41+
-t, --increment <increment> enable increment export snapshot
42+
-n, --net <net> Chain Network, like main, proxima
43+
-o, --output <output> output dir, like ~/, manifest.csv will write in output dir
44+
```
45+
this cmd use increment export snapshot data, dir ~/snapshot have old snapshot data, like ~/snpashot is the 1-400w block height
46+
snapshot data, then want get 1-500w block height snapshot data, use this cmd will export 400w-500w block snapshot data, then merge
47+
with old snapshot data gen new snapshot data
48+
### offline import snapshot
49+
#### use`starcoin_db_exporter` offline import
50+
```shell
51+
./starcoin_db_exporter apply-snapshot -i ~/snapshot -n main -o ~/.starcoin/main
52+
USAGE:
53+
starcoin_db_exporter apply-snapshot --input-path <input-path> --net <net> --to-path <to-path>
54+
55+
FLAGS:
56+
-h, --help Prints help information
57+
-V, --version Prints version information
58+
59+
OPTIONS:
60+
-i, --input-path <input-path> input_path, manifest.csv in this dir
61+
-n, --net <net> Chain Network
62+
-o, --to-path <to-path> starcoin node db path. like ~/.starcoin/main
63+
```
64+
65+
#### use `import_snapshot.sh` offline import snapshot
66+
`starcoin_db_exporter`and`import_snapshot.sh` under same path
67+
`import_net_block.sh $1 $2`
68+
$1 is net node like main, barnard
69+
$2 is import_snapshot.sh download snapshot which dir
70+
$3 is storage dir like ~/.starcoin/main, ~/.starcoin/barnard
71+
72+
run cmd
73+
```shell
74+
./import_snapshot.sh barnard ~/snapshot/ ~/.starcoin/barnard
75+
```
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: 导出导入快照
3+
weight: 4
4+
---
5+
`starcoin_db_exporter`命令行工具提供了离线导出导入
6+
main,barnard,halley, proxima网络的快照功能,这样可以快速的搭建区块链网络
7+
离线导入快照也可以使用import_net_block.sh脚本
8+
9+
<!--more-->
10+
11+
## 使用方法
12+
### 快照导出
13+
使用`starcoin_db_exporter`命令导出快照
14+
执行命令
15+
```shell
16+
./starcoin_db_exporter export-snapshot -i ~/.starcoin/main -n main -o ~/snapshot
17+
USAGE:
18+
starcoin_db_exporter export-snapshot [OPTIONS] --db-path <db-path> --net <net> --output <output>
19+
20+
FLAGS:
21+
-h, --help Prints help information
22+
-V, --version Prints version information
23+
24+
OPTIONS:
25+
-i, --db-path <db-path> starcoin node db path. like ~/.starcoin/main
26+
-t, --increment <increment> enable increment export snapshot
27+
-n, --net <net> Chain Network, like main, proxima
28+
-o, --output <output> output dir, like ~/, manifest.csv will write in output dir
29+
```
30+
上面例子中将快照导出为~/snapshot目录下,导出快照可能需要1-2小时时间(看具体机器配置)
31+
32+
增量导出快照
33+
```shell
34+
./starcoin_db_exporter export-snapshot -i ~/.starcoin/main -n main -o ~/snapshot -t true
35+
USAGE:
36+
starcoin_db_exporter export-snapshot [OPTIONS] --db-path <db-path> --net <net> --output <output>
37+
38+
FLAGS:
39+
-h, --help Prints help information
40+
-V, --version Prints version information
41+
42+
OPTIONS:
43+
-i, --db-path <db-path> starcoin node db path. like ~/.starcoin/main
44+
-t, --increment <increment> enable increment export snapshot
45+
-n, --net <net> Chain Network, like main, proxima
46+
-o, --output <output> output dir, like ~/, manifest.csv will write in output dir
47+
```
48+
上面例子使用增量导出,需要~/snapshot目录下有旧的快照, 比如原来~/snapshot下快照为1-400w高度的快照, 现在要导1-500w高度快照,
49+
会把后面400w-500w快照导出后与原来合并,节省时间
50+
51+
### 快照离线导入
52+
#### 使用`starcoin_db_exporter`离线导入
53+
```shell
54+
./starcoin_db_exporter apply-snapshot -i ~/snapshot -n main -o ~/.starcoin/main
55+
USAGE:
56+
starcoin_db_exporter apply-snapshot --input-path <input-path> --net <net> --to-path <to-path>
57+
58+
FLAGS:
59+
-h, --help Prints help information
60+
-V, --version Prints version information
61+
62+
OPTIONS:
63+
-i, --input-path <input-path> input_path, manifest.csv in this dir
64+
-n, --net <net> Chain Network
65+
-o, --to-path <to-path> starcoin node db path. like ~/.starcoin/main
66+
```
67+
#### 使用`import_snapshot.sh`离线导入
68+
`starcoin_db_exporter``import_snapshot.sh`在同一路径下
69+
`import_net_block.sh $1 $2 `
70+
$1是网络名称可以是main, barnard
71+
$2是指定import_snapshot.sh下载快照路径
72+
$3是数据存储的地方,可以使用~/.starcoin/main, ~/.starcoin/barnard
73+
74+
执行命令
75+
```shell
76+
./import_snapshot.sh barnard ~/snapshot/ ~/.starcoin/barnard
77+
```
78+

0 commit comments

Comments
 (0)