You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+95-51Lines changed: 95 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,5 @@
1
+
# Migration from SQLite to MySQL/MariaDB
2
+
1
3
---
2
4
3
5
## ⚠️ Important: Table name case-sensitivity in MySQL/MariaDB
@@ -17,7 +19,7 @@ If you encounter "table not found" errors after migration, review your server se
17
19
18
20
If you encounter an error like the following during migration:
19
21
20
-
```
22
+
```text
21
23
* MySQL Error [1064]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ...
22
24
* Error Query: SET group_concat_max_len = 1024 * 1024 * 100;SELECT CONCAT('SELECT * FROM (',GROUP_CONCAT(...)
23
25
@@ -35,10 +37,12 @@ TypeError: 'NoneType' object is not iterable
35
37
```
36
38
37
39
### What does this mean?
40
+
38
41
- The script attempted to run a dynamic SQL query that failed due to a syntax error (error 1064).
39
42
- After the SQL error, the script tried to process the result, but since the query failed, the result was `None`, causing a Python `TypeError`.
40
43
41
44
### How to troubleshoot
45
+
42
46
- Carefully check the SQL error message and the problematic query shown after `* Error Query:`.
43
47
- Review your MySQL/MariaDB version and compatibility with the generated SQL.
44
48
- Check the value of `lower_case_table_names` and your table names for case-sensitivity issues (see section above).
@@ -48,28 +52,28 @@ If you need help, include the full error output (including the SQL and Python tr
48
52
49
53
---
50
54
51
-
# Migration procedure
55
+
##Migration procedure
52
56
53
-
* 1\.[Requirements](#1-requirements)
54
-
* 2\.[Create database and user in the server MySql/MariaDB](#2-create-database-and-user-in-the-server-mysqlmariadb)
55
-
*2.1\.[A Single Database](#21-a-single-database)
56
-
*2.2\.[In Multiple DataBases or Servers MySql/MariaDB](#22-in-multiple-databases-or-servers-mysqlmariadb)
57
-
* 3\.[Download Script and install dependencies](#3-download-script-and-install-dependencies)
58
-
* 4\.[Create and prepare tables](#4-create-and-prepare-tables)
> This would be the procedure to migrate the Ombi databases from SQLite to a MySQL/MariaDB server.
66
-
>
67
-
> If there is an error you can contact Discour or you can open an incident [here](https://github.com/vsc55/ombi_sqlite_mysql/issues).
68
-
70
+
>
71
+
> If there is an error you can contact Discour or you can open an incident on [GitHub Issues](https://github.com/vsc55/ombi_sqlite_mysql/issues).
69
72
70
73
## 1. Requirements
71
-
* Python3
72
-
* Ombi version 4.0.728 or higher
74
+
75
+
- Python3
76
+
- Ombi version 4.0.728 or higher
73
77
74
78
## 2. Create database and user in the server MySql/MariaDB
75
79
@@ -78,13 +82,15 @@ On the MySQL/MariaDB server we will create the database and the user that we wil
78
82
> **NOTE: Just follow one of the following two points. Point 2.1 if we want to use a single database, or point 2.2 if we want to separate the databases.**
79
83
80
84
### 2.1. A Single Database
85
+
81
86
```mysql
82
87
CREATEDATABASEIF NOT EXISTS `Ombi` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
83
88
CREATEUSER 'ombi'@'%' IDENTIFIED BY 'ombi';
84
89
GRANT ALL PRIVILEGES ON`Ombi`.* TO 'ombi'@'%' WITH GRANT OPTION;
85
90
```
86
91
87
92
### 2.2. In Multiple DataBases or Servers MySql/MariaDB
93
+
88
94
```mysql
89
95
CREATEDATABASEIF NOT EXISTS `Ombi` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
90
96
CREATEDATABASEIF NOT EXISTS `Ombi_Settings` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
@@ -94,50 +100,61 @@ GRANT ALL PRIVILEGES ON `Ombi`.* TO 'ombi'@'%' WITH GRANT OPTION;
94
100
GRANT ALL PRIVILEGES ON`Ombi_Settings`.* TO 'ombi'@'%' WITH GRANT OPTION;
95
101
GRANT ALL PRIVILEGES ON`Ombi_External`.* TO 'ombi'@'%' WITH GRANT OPTION;
96
102
```
97
-
> _You need to GRANT ALL PRIVILEGES for every database you create._
103
+
104
+
> *You need to GRANT ALL PRIVILEGES for every database you create.*
2. Install the dependencies according to the operating system we use.
109
-
1. Lib python-mysqldb:
119
+
2.1. Lib python-mysqldb:
120
+
110
121
```bash
111
-
$ emerge -va dev-python/mysqlclient # Gentoo
112
-
$ pip3 install mysqlclient # Python Pip
113
-
$ python3 -m pip install mysqlclient # Python Pip
122
+
emerge -va dev-python/mysqlclient # Gentoo
123
+
pip3 install mysqlclient # Python Pip
124
+
python3 -m pip install mysqlclient # Python Pip
114
125
```
126
+
115
127
> WARNING: It is not recommended to use the python3-mysqldb package on Debian/Ubutu systems as the version it installs fails with modern versions of MariaDB/MySQL.
Migration tool from SQLite to MySql/MariaDB for ombi (3.0.4) By VSC55
134
149
135
150
Generate file "database.json":
136
151
- Saving in (/etc/Ombi/database.json)... [✓]
137
152
```
153
+
138
154
4. **Only if we are going to use *Multiple DataBases* or *Multiple Servers*.**
139
155
140
156
To be able to use multiple servers or databases we will need to manually edit **database.json**.
157
+
141
158
```json
142
159
$ vi database.json
143
160
{
@@ -155,17 +172,20 @@ GRANT ALL PRIVILEGES ON `Ombi_External`.* TO 'ombi'@'%' WITH GRANT OPTION;
155
172
}
156
173
}
157
174
```
175
+
158
176
> The example above will export the **"OmbiDatabase"** and **"SettingsDatabase"** databases to server **"192.168.0.100"** but to different databases on the same server, while the **"ExternalDatabase"** database will be sent to server **"192.168.1.200"**.
159
177
160
178
5. Run the following command:
161
-
```
162
-
$ /opt/ombi/Ombi --migrate
179
+
180
+
```bash
181
+
/opt/ombi/Ombi --migrate
163
182
```
164
183
165
184
>**Note:**
166
185
If our sqlite database and json configuration files are stored in a different location than the one where we have Ombi installed, we will have to add the --storage argument.
186
+
167
187
```bash
168
-
$ /opt/ombi/Ombi --migrate --storage /etc/Ombi
188
+
/opt/ombi/Ombi --migrate --storage /etc/Ombi
169
189
```
170
190
171
191
>**Note:**
@@ -174,20 +194,21 @@ GRANT ALL PRIVILEGES ON `Ombi_External`.* TO 'ombi'@'%' WITH GRANT OPTION;
174
194
175
195
[Go Up](#migration-procedure)
176
196
177
-
178
197
## 5. Data Migration
179
198
180
199
When it comes to migrating the data, we have several different ways of doing it.
181
200
We can export everything to a single database (step 5.1), to different databases or to different mysql servers (step 5.2).
182
201
183
202
### 5.1. Data Migration (*Single Database*)
203
+
184
204
> For data migration we will need the file **"migration.json"** that contains the locations of the SQLite databases.
185
-
>
205
+
>
186
206
> If this file does not exist, it will be created and will search the databases in the folder specified with the parameter **"--config"**.
187
207
>
188
208
>If we don't want to migrate all the data, we can generate the file **"migration.json"** with the parameter **"--only_manager_json"** and then edit it by deleting the databases we don't want to migrate.
@@ -255,15 +278,17 @@ We can export everything to a single database (step 5.1), to different databases
255
278
256
279
MySQL > Disconnecting... [✓]
257
280
```
281
+
258
282
2. Start ombi and testif everything works fine.
259
283
260
284
[Go Up](#migration-procedure)
261
285
262
-
263
286
### 5.2. Data Migration (*Multiple DataBases or Servers MySql/MariaDB*)
287
+
264
288
> For data migration to multiple databases or servers we will need the file **"database_multi.json"** that contains the locations of the servers where we are going to export the data.
265
289
266
290
1. To create the file **"database_multi.json"** we will use the file **"database.json"** so we will only have to rename it.
291
+
267
292
```json
268
293
$ vi database_multi.json
269
294
{
@@ -284,6 +309,7 @@ We can export everything to a single database (step 5.1), to different databases
284
309
285
310
> We can omit the export of a database by removing it from **"database_multi.json"** or adding the property **"Skip"**.
286
311
> The example next will export the databases **"OmbiDatabase"** and **"SettingsDatabase"** but omit **"ExternalDatabase"**.
312
+
287
313
```json
288
314
$ vi database_multi.json
289
315
{
@@ -305,6 +331,7 @@ We can export everything to a single database (step 5.1), to different databases
305
331
306
332
> We can also send the same database to different servers with the following configuration.
307
333
> The example next sends databases "OmbiDatabase", "SettingsDatabase" and "ExternalDatabase" to servers 192.168.1.100 and 192.168.1.200.
334
+
308
335
```json
309
336
$ vi database_multi.json
310
337
{
@@ -334,10 +361,13 @@ We can export everything to a single database (step 5.1), to different databases
334
361
}
335
362
}
336
363
```
337
-
>### NOTE: If you want to export all the content to several servers we will have to repeat the point "Create and prepare tables" with the different servers so that all the tables are created. You will also have to modify the file **database.json** at the end of the export process before running ombi to leave a single server for each database.
364
+
365
+
> [!IMPORTANT]
366
+
> If you want to export all the content to several servers we will have to repeat the point "Create and prepare tables" with the different servers so that all the tables are created. You will also have to modify the file **database.json** at the end of the export process before running ombi to leave a single server for each database.
338
367
339
368
2. Start data migration.
340
369
> The script will empty the tables from the MySQL/MariaDB database and automatically migrate the data from SQLite to MySQL/MariaDB.
370
+
341
371
```bash
342
372
$ python ombi_sqlite2mysql_multi.py -c /etc/Ombi
343
373
Migration tool from SQLite to Multi MySql/MariaDB for ombi (1.0.0) By VSC55
@@ -489,8 +519,8 @@ We can export everything to a single database (step 5.1), to different databases
489
519
490
520
[Go Up](#migration-procedure)
491
521
492
-
493
522
## 6. Help
523
+
494
524
```bash
495
525
$ python ombi_sqlite2mysql.py -h
496
526
Migration tool from SQLite to MySql/MariaDB for ombi (3.0.4) By VSC55
@@ -535,10 +565,10 @@ Options:
535
565
536
566
[Go Up](#migration-procedure)
537
567
568
+
## 7. F.A.Q. (Frequently Asked Questions)
538
569
539
-
## 7. F.A.Q.
570
+
**P:** Errors appear in the verification of the migrated data saying that there is more data in SQLite than in MySQL or vice versa.
540
571
541
-
**P: Errors appear in the verification of the migrated data saying that there is more data in SQLite than in MySQL or vice versa.**
S: This error has been detected in debian when using the python3-mysqldb library installed from apt.
627
-
The version installed with apt (1.3.10-2) is old and produces the error with newer databases. The solution is to install the library with pip since the version (2.1.0) installed with pip works correctly.
664
+
The version installed with apt (1.3.10-2) is old and produces the error with newer databases. The solution is to install the library with pip since the version (2.1.0) installed with pip works correctly.
665
+
628
666
```bash
629
-
$ apt-get remove python3-mysqldb
630
-
$ pip3 install mysqlclient
667
+
apt-get remove python3-mysqldb
668
+
pip3 install mysqlclient
631
669
```
670
+
632
671
---
633
-
**P: Table "XXX" requiered is not exist in the server MySQL**
672
+
673
+
**P:** Table "XXX" requiered is not exist in the server MySQL
Migration tool from SQLite to MySql/MariaDB for ombi (3.0.8) By VSC55
@@ -645,12 +686,15 @@ Read tables [!!]
645
686
646
687
MySQL > Disconnecting... [✓]
647
688
```
689
+
648
690
S: This error typically occurs when tables were not successfully created with the --migrate argument to ombi. This may be because the configuration (database.json file) and the databases are not in the same folder where we have installed ombi. The solution is to add the --storage argument when we run the migration.
649
691
650
692
In the following example, both the database.json file and the databases are stored in /etc/Ombi:
0 commit comments