Move of Data Directory

Hi,

I just set up a xWiki Server on my Raspberry Pi 4. And I am very proud to say, It works fine :slight_smile:

There is only one issue, where I could use your help. At the moment the Database of my xWiki is placed on the SD Card of my Pi.

I would like to move this Database to my NAS.

  1. Is this possible?
  2. If not, what have I to do during the installation of XWiki to get the Database on the NAS?

Thanks a lot in advance!

PS: I a am a complete noob considering linux :wink:

Sven
This depends on many factors like what Database you have in use (e.g. how you installed xWiki) and what capabilities the NAS has (native DB support, only store the files of the local DB on the NAS [not recommended anyway]). IMHO, only viable option is if your NAS can run a supported DB on the NAS itself)

You can backup the DB on the PI to your NAS though.
HTH

I just found out, that my NAS is already running a MySQL Database.

I installed XWiki standalone. There is no problem to reinstall the complete system. During install I can chose to let XWiki install the standard database or to configure manually.

I don’t want the database on the SD Card due to the many I/Os.

The question is how do have I configure XWiki to to use the MySQL Database on the NAS.

You need to create a database on the MySQL Server on your NAS first, then configure hibernate to use this database. Create a dedicated database and user for xWiki on your NAS.
You further need an JDBC driver to make this work. I just dump my documentation I did some time ago:

cd WEB-INF

cp hibernate.cfg.xml hibernate.cfg.xml.org
vi hibernate.cfg.xml

should then look somehting like

<property name="connection.url">jdbc:mysql://localhost/ns_xWIKI_Internal?useSSL=false</property>
<property name="connection.username">ns_xwiki_XXXXX</property>
<property name="connection.password">XXXXXXXXXX</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="dbcp.poolPreparedStatements">true</property>
<property name="dbcp.maxOpenPreparedStatements">20</property>
<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
<mapping resource="mailsender.hbm.xml"/>

IMPORTANT: note that the --> was moved before the parameters! Otherwise, the settings would not apply

IMPORTANT: you also need to comment out (disable) the default database!

<!-- Configuration for the default database.
     Comment out this section and uncomment other sections below if you want to use another database.
     Note that the database tables will be created automatically if they don't already exist.

     If you want the main wiki database to be different than "xwiki" (or the default schema for schema based engines)
     you will also have to set the property xwiki.db in xwiki.cfg file
-->
<property name="connection.url">jdbc:hsqldb:file:${environment.permanentDirectory}/database/xwiki_db;shutdown=true</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>

<property name="hibernate.connection.charSet">UTF-8</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">utf8</property>

<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
<mapping resource="mailsender.hbm.xml"/>

should be

<!-- Configuration for the default database.
     Comment out this section and uncomment other sections below if you want to use another database.
     Note that the database tables will be created automatically if they don't already exist.

     If you want the main wiki database to be different than "xwiki" (or the default schema for schema based engines)
     you will also have to set the property xwiki.db in xwiki.cfg file

<property name="connection.url">jdbc:hsqldb:file:${environment.permanentDirectory}/database/xwiki_db;shutdown=true</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>

<property name="hibernate.connection.charSet">UTF-8</property>
<property name="hibernate.connection.useUnicode">true</property>ZZ
<property name="hibernate.connection.characterEncoding">utf8</property>

<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
<mapping resource="mailsender.hbm.xml"/>

-->

Provide MySQL ODBC Driver

BUT: this would require much re-configuration of the hibernate configuration, so we use the simpler approach and use the MySQL one, since those are 100% compatible

HTH

1 Like

Hey, Thank you very much. As a linux noob it took me a while, but now all is up and running!