Skip to content

Commit 8b1910b

Browse files
committed
#23 migration from TH 3.4.x and 3.5.x to TH 4.1.17 and higher
1 parent 2634775 commit 8b1910b

File tree

1 file changed

+63
-37
lines changed

1 file changed

+63
-37
lines changed

docs/thehive/operations/migration.md

+63-37
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,13 @@ TheHive 4.x is delivered with a tool to migrate your data from TheHive 3.x. stor
44

55
## Supported versions
66

7-
The tool is provided with TheHive 4.x. Depending on the target version, the migration tool supports specific versions. Here is a summary:
7+
Starting with TheHive 4.1.17, the migration tool supports migrating data from both TheHive 3.4.x and 3.5.x.
88

9+
| Migrating from | Possible target version |
10+
| ---------------------------------- | ----------------------- |
11+
| TheHive 3.4.x + Elasticsearch 6.x | TheHive 4.1.17+ |
12+
| TheHive 3.5.x + Elasticsearch 7.x | TheHive 4.1.17+ |
913

10-
| Migrating from | Possible target version |
11-
| --------------- | ----------------------- |
12-
| TheHive 3.4.x | TheHive 4.0.x |
13-
| TheHive 3.5.x | TheHive 4.1.x |
14-
15-
16-
!!! Warning ""
17-
18-
=== "Using TheHive 3.4.x"
19-
You can only migrate to TheHive 4.0.x. After that, an update to TheHive 4.1.x will be possible.
20-
21-
Technically, many reasons explain this limitation:
22-
23-
- A new database format has been introduced with TheHive 3.4.0,
24-
- Elasticsearch 6.x came with changes in data structure (mostly related to the definition of document relations)
25-
26-
So, if you want to migrate your data from TheHive 3 to TheHive 4.0, you are invited to update your current instance to TheHive 3.4.0+ before.
27-
28-
=== "Using TheHive 3.5.x"
29-
You can only process to the migration to TheHive 4.1.x.
30-
31-
32-
=== "Using older versions"
33-
You need to update your database at least to TheHive 3.4.0.
3414

3515
## How it works
3616

@@ -42,8 +22,8 @@ In order to migrate the data:
4222

4323
- TheHive 4 **must** be installed on the system running the migration tool;
4424

45-
- TheHive4 **must** be configured ; in particular **database** and **file storage** ;
46-
- The service `thehive` **must be stopped** (`service thehive stop`) .
25+
- TheHive4 **must** be configured ; in particular **database**, **index**, and **file storage** ;
26+
- The service `thehive` **must be stopped** (`service thehive stop`) on the target server.
4727

4828
This tools **must** also have access to Elasticsearch database (http://ES:9200) used by TheHive 3, and the configuration file of TheHive 3.x instance.
4929

@@ -52,7 +32,7 @@ This tools **must** also have access to Elasticsearch database (http://ES:9200)
5232
!!! Warning
5333
In TheHive4, users are identified by their email addresses. Thus, a domain will be appended to usernames in order to migrate users from TheHive 3.
5434

55-
TheHive 4.0 comes with a default domain named `thehive.local`. Starting the migration without explicitely specifying a domain name will result in migrating all users with a username formatted like `[email protected]`.
35+
TheHive 4.x comes with a default domain named `thehive.local`. Starting the migration without explicitely specifying a domain name will result in migrating all users with a username formatted like `[email protected]`.
5636

5737
Change the default domain name used to import existing users in the configuration file of TheHive4 (`/etc/thehive/application.conf`) ; add or update the setting named `auth.defaultUserDomain`:
5838

@@ -67,29 +47,44 @@ This tools **must** also have access to Elasticsearch database (http://ES:9200)
6747

6848
Prepare, install and configure your new instance of TheHive 4.x by following [the associated guides](../installation-and-configuration/index.md).
6949

70-
Once TheHive4 configuration file (`/etc/thehive/application.conf`) is correctly filled you can run migration tool.
50+
Once TheHive4 configuration file (`/etc/thehive/application.conf`) is correctly filled the `migrate` command ca be executed.
51+
52+
!!! Info
53+
This recommended to run this program as the user in charge of running TheHive service ( `thehive` if you are installing the application with DEB or RPM package)
54+
7155

7256
The program comes with a large set of options:
7357

7458
```
7559
# /opt/thehive/bin/migrate --help
76-
TheHive migration tool 4.0.4-1
60+
TheHive migration tool 4.1.17-1
7761
Usage: migrate [options]
7862
7963
-v, --version
8064
-h, --help
65+
-l, --logger-config <file>
66+
logback configuration file
8167
-c, --config <file> global configuration file
8268
-i, --input <file> TheHive3 configuration file
8369
-o, --output <file> TheHive4 configuration file
8470
-d, --drop-database Drop TheHive4 database before migration
71+
-r, --resume Resume migration (or migrate on existing database)
8572
-m, --main-organisation <organisation>
8673
-u, --es-uri http://ip1:port,ip2:port
8774
TheHive3 ElasticSearch URI
88-
-i, --es-index <index> TheHive3 ElasticSearch index name
75+
-e, --es-index <index> TheHive3 ElasticSearch index name
76+
-x, --es-index-version <index>
77+
TheHive3 ElasticSearch index name version number (default: autodetect)
8978
-a, --es-keepalive <duration>
9079
TheHive3 ElasticSearch keepalive
9180
-p, --es-pagesize <value>
9281
TheHive3 ElasticSearch page size
82+
-s, --es-single-type <bool>
83+
Elasticsearch single type
84+
-y, --transaction-pagesize <value>
85+
page size for each transaction
86+
-t, --thread-count <value>
87+
number of threads
9388
--max-case-age <duration>
9489
migrate only cases whose age is less than <duration>
9590
--min-case-age <duration>
@@ -133,6 +128,8 @@ Usage: migrate [options]
133128
migration only audits with this objectType (case, case_artifact, case_task, ...)
134129
--exclude-audit-objectTypes <value>
135130
don't migration audits with this objectType (case, case_artifact, case_task, ...)
131+
--case-number-shift <value>
132+
transpose case number by adding this value
136133
Accepted date formats are "yyyyMMdd[HH[mm[ss]]]" and "MMdd"
137134
The Format for duration is: <length> <unit>.
138135
Accepted units are:
@@ -170,8 +167,40 @@ with:
170167
| `--es-index` | specifies the index used in Elasticsearch. |
171168

172169

170+
!!! Example
173171

174-
!!! Warning
172+
=== "TheHive 3.4.x + Elasticsearch 6.x "
173+
174+
When migrating, start a new database, create an organisation named `StrangeBee`, add all users in this organisation, and **do not keep** audit trails older than 90d.
175+
176+
!!! Warning "Requirements"
177+
The option `--es-single-type true` is **mandatory** to migrate data from Elasticsearch 6.x
178+
179+
```bash
180+
/opt/thehive/bin/migrate \
181+
--drop-database \
182+
--input /etc/thehive/thehive3.conf \
183+
--output /etc/thehive/application.conf \
184+
--main-organisation StrangeBee \
185+
--max-audit-age 90d \
186+
--es-single-type true
187+
```
188+
189+
=== "TheHive 3.5.x + Elasticsearch 7.x"
190+
191+
When migrating, start a new database, create an organisation named `StrangeBee`, add all users in this organisation, and **do not keep** alert trails created before the March, 25th of 2019.
192+
193+
```bash
194+
/opt/thehive/bin/migrate \
195+
--drop-database \
196+
--input /etc/thehive/thehive3.conf \
197+
--output /etc/thehive/application.conf \
198+
--main-organisation StrangeBee \
199+
--alert-from-date 20190325
200+
```
201+
202+
203+
!!! Info
175204
The migration process can be very long, from several hours to several days, depending on the volume of data to migrate. We **highly** recommand to not start the application during the migration.
176205

177206

@@ -188,14 +217,11 @@ GRANT CREATE on ALL KEYSPACES to username;
188217

189218
The migration tool generates some logs during the process. By default, every 10 sec. a log is generated with information regarding the situation of the migration:
190219

191-
```log
220+
```
192221
[info] o.t.t.m.Migrate - [Migrate cases and alerts] CaseTemplate/Task:32 Organisation:1/1 Case/Task:160/201 Case:31/52 Job:103/138 ObservableType:3/17 Alert:25/235 Audit:3207/2986 CaseTemplate:6/6 Alert/Observable:700(52ms) Case/Observable:1325/1665 User:9/9 CustomField:13/13 Case/Task/Log:20/27
193222
```
194223

195-
!!! Warning
196-
Numbers of Observables, Cases and others are estimations and not a definite value as computing these number can be very tedious.
197-
198-
224+
Numbers of Observables, Cases and others are estimations and not a definite value as computing these number can be very tedious.
199225

200226
!!! Info "Files from MISP imported with TheHive 2.13 and earlier"
201227
It is important to notice that migrating Cases/Alerts containing MISP event that were imported with TheHive 2.13 (_Sept 2017_) or older, will cause observable files not being imported in TheHive 4.

0 commit comments

Comments
 (0)