If you use the Debian package you don’t need to do anything. But the owner of the files in /var/lib/xwiki/data is supposed to be tomcat user and since you copied those files yourself I guess you did not change the owner.
That’s really surprising as I can see various warnings in the code in case of problems with the configured permanent directory.
I just tried to configure a not writable permanent directory and I do get an error
2023-01-13 14:31:54,302 [main] INFO iPropertiesConfigurationSource - Loading [xwiki.properties] from [file:/media/DATA/xwiki/test/xwiki-platform-distribution-flavor-jetty-hsqldb-14.10/webapps/xwiki/WEB-INF/xwiki.properties]
2023-01-13 14:31:54,377 [main] ERROR o.x.e.i.ServletEnvironment - Configured permanent directory [/media/DATA/xwiki/test/xwiki-platform-distribution-flavor-jetty-hsqldb-14.10/data] is not writable.
2023-01-13 14:31:54,377 [main] WARN o.x.e.i.ServletEnvironment - Falling back on [/tmp/jetty-0_0_0_0-8080-xwiki-_xwiki-any-17667244892667511766] as the permanent directory.
2023-01-13 14:31:54,377 [main] INFO o.x.e.i.ServletEnvironment - Using permanent directory [/tmp/jetty-0_0_0_0-8080-xwiki-_xwiki-any-17667244892667511766]
I have change the ownership of /var/lib/xwiki/data (and sub-dirs) to the main user. Now I got:
jan 13 15:04:14 thehub tomcat9[742]: 2023-01-13 15:04:14,051 [main] WARN o.e.j.u.s.S.config - No Client EndPointIdentificationAlgorithm configured for Client@63be03c8[provider=null,keyStore=null,trustStore=null]
jan 13 15:04:14 thehub tomcat9[742]: 2023-01-13 15:04:14,122 [main] WARN o.a.s.c.CoreContainer - Not all security plugins configured! authentication=disabled authorization=disabled. Solr is only as secure as you make it. Consider configuring authentication/authorization before exposing Solr to users internal or external. See https://s.apache.org/solrsecurity for more info
jan 13 15:04:16 thehub tomcat9[742]: 2023-01-13 15:04:16,693 [main] INFO o.x.s.s.i.EmbeddedSolr - Started embedded Solr server.
jan 13 15:04:18 thehub tomcat9[742]: 2023-01-13 15:04:18,217 [main] INFO o.x.s.f.i.FilesystemStoreTools - Using filesystem store directory [/var/cache/tomcat9/Catalina/localhost/xwiki/store/file]
This went totally over my head. I thought you meant the user who set up tomcat, while it is literally user named tomcat. Now it works. Thank you @tmortagne so much for your help and patience!
Here are the steps I took so people struggling with similar issue have everything in one place.
Starting from a fresh system:
Installed Xwiki with Tomcat and MySQL (apt install xwiki-tomcat9-common xwiki-tomcat9-mariadb -y)
Stoped both services (systemctl stop mariadb, systemctl stop tomcat9)
Removed data dir from /var/lib/xwiki/
Move data dir copied from the original xwiki to /var/lib/xwiki/
Changed the owner of data (chown -R tomcat:tomcat data)
Copied hibernate.cfg.xml , xwiki.cfg , xwiki.properties , logback.xml , observation to /etc/xwiki/ (with -r, observation is a dir)
Restored the database
mysql -e "SET FOREIGN_KEY_CHECKS=0;"
mysql -e "DROP DATABASE xwiki;"
mysql -e "CREATE DATABASE IF NOT EXISTS xwiki DEFAULT CHARACTER SET utf8;"
mysql xwiki --user=root -p < xwiki_db.sql
mysql -e "SET FOREIGN_KEY_CHECKS=1;"
Updated password
pass=$(cat /etc/xwiki/hibernate.cfg.xml | grep passw| head -1 | sed -e 's/^.*<prop.*password">//' | sed -e 's|</property>.*||')
mysql -e "SET PASSWORD FOR 'xwiki'@'localhost' = PASSWORD('$pass');"
Rebooted system
Opened wiki in a browser (http://127.0.0.1:8080/xwiki) - Here I’ve got a warning that the version I have installed is not valid
Updated to the newest version by clicking a juicy “Update” button