Wiki source code of Repair Corrupted Internal Database
Last modified by michaely on 2021/09/10 22:40
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | In some cases the internal database can become corrupt and prevent use of the iSymphony application. Users will normally see errors like the following when accessing the panel: | ||
2 | |||
3 | {{info}} | ||
4 | The error may vary slightly from the example below. | ||
5 | {{/info}} | ||
6 | |||
7 | {{code}} | ||
8 | org.apache.ibatis.exceptions.PersistenceException: | ||
9 | ### Error querying database. Cause: org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: rowcount remaining=5 SYS" [50000-169] | ||
10 | ### The error may exist in com/xmlnamespace/panel/server/core/pbx/callhistory/CallHistoryMapper.xml | ||
11 | ### The error may involve com.xmlnamespace.panel.server.core.pbx.callhistory.CallHistoryMapper.getByExtension | ||
12 | ### The error occurred while executing a query | ||
13 | ### Cause: org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: rowcount remaining=5 SYS" [50000-169] | ||
14 | {{/code}} | ||
15 | |||
16 | == Repair Process == | ||
17 | |||
18 | In order to recover your data, you will need to run a repair process on the database. The repair process is outlined below: | ||
19 | |||
20 | 1. Stop the iSymphony server. See [[doc:ISYMDOCS.Starting And Stopping The iSymphony Server]]. | ||
21 | 1. ((( | ||
22 | Create a temporary directory to perform the recovery.(% style="color: rgb(60,62,67);font-family: Verdana , Arial , Helvetica;font-size: small;line-height: 17.7273px;background-color: rgb(248,248,248);" %) | ||
23 | |||
24 | |||
25 | {{code language="bash"}} | ||
26 | mkdir isdbrecovery | ||
27 | cd isdbrecovery | ||
28 | {{/code}} | ||
29 | |||
30 | {{note}} | ||
31 | Do not create this directory anywhere inside the **/opt/isymphony3** directory. | ||
32 | {{/note}} | ||
33 | ))) | ||
34 | 1. ((( | ||
35 | Copy the h2 database jar into the recovery directory: | ||
36 | |||
37 | {{code language="bash"}} | ||
38 | cp /opt/isymphony3/server/modules/framework/shared/org.h2_1.3.169.jar . | ||
39 | {{/code}} | ||
40 | ))) | ||
41 | 1. ((( | ||
42 | Copy the database file into the recovery directory: | ||
43 | |||
44 | {{code language="bash"}} | ||
45 | cp /opt/isymphony3/server/conf/servers/default/isymphony.h2.db . | ||
46 | {{/code}} | ||
47 | |||
48 | {{info}} | ||
49 | If you have Core Servers other than default you will need to replace default with the slug of the core server you are repairing the database for. | ||
50 | {{/info}} | ||
51 | ))) | ||
52 | 1. ((( | ||
53 | Run the following command to export the database to an sql file: | ||
54 | |||
55 | {{code language="bash"}} | ||
56 | java -cp org.h2_1.3.169.jar org.h2.tools.Recover | ||
57 | {{/code}} | ||
58 | ))) | ||
59 | 1. ((( | ||
60 | Create a sub directory to hold the old database: | ||
61 | |||
62 | {{code language="bash"}} | ||
63 | mkdir old | ||
64 | mv isymphony.h2.db ./old | ||
65 | {{/code}} | ||
66 | ))) | ||
67 | 1. ((( | ||
68 | Run the following command to create a new database from the sql file: | ||
69 | |||
70 | {{code language="bash"}} | ||
71 | java -cp org.h2_1.3.169.jar org.h2.tools.RunScript -url "jdbc:h2:./isymphony" -user admin -password admin -script isymphony.h2.sql | ||
72 | {{/code}} | ||
73 | ))) | ||
74 | 1. ((( | ||
75 | Move the new database into place: | ||
76 | |||
77 | {{code language="bash"}} | ||
78 | mv isymphony.h2.db /opt/isymphony3/server/conf/servers/default/ | ||
79 | {{/code}} | ||
80 | |||
81 | {{info}} | ||
82 | If you have Core Servers other than default you will need to replace default with the slug of the core server you are repairing the database for. | ||
83 | {{/info}} | ||
84 | ))) | ||
85 | 1. ((( | ||
86 | Ensure that the new h2.db file has the same ownership and permissions as the original file. | ||
87 | ))) | ||
88 | 1. ((( | ||
89 | Restart iSymphony. See [[doc:ISYMDOCS.Starting And Stopping The iSymphony Server]]. | ||
90 | ))) |