Migrate Piwik from one database to another and to a different Matomo version


#1

We are currently using Piwik 2. I would like to know if we can move all the data to a new server and to a new version. In this FAQ it is mentioned that I should make the migration using the same version. Is it possible to use a different Matomo version since our current version is very old?

Also, the Matomo will be using a different domain.

Edit: I should mention that we are considering of keeping all the existing data and the current users, access rights and siteIds.


(Lukas Winkler) #2

Hi,

If you are also migrating the config.ini.php and are using the new files on the new server it should work just like a normal manual update.

So make a backup to be save, but it should work.


#3

Hello,

Could you please be a bit more detailed about the procedure? If I make a Matomo 3.9.1 installation in the new server, move all the tables from the old database to the new database, and use that new database (containing all Piwik 2 logs) for the new installation, will it just work fine?

What happens to the naming of the tables, from example piwik -> matomo in the tables names etc?


(Lukas Winkler) #4

Hi,

You don’t need to actually go through the installation setup on the new server as it only creates the config file (that you already have).

You probably need to update the MySQL details in the config file as the new server has a new user/password.

The table prefix doesn’t matter as it is specified in the config file and only the default for new installs changed to matomo_


#5

So I should just move Piwik database to a new database and use that new database with the latest Matomo version with no complications? Just changing the database parameters in the config.ini.php file?

Then why is it mentioned in the FAQ that Matomo should have the same version when moving to a different server?


(Lukas Winkler) #6

If you don’t copy over the config file, you can regenerate it by going through the installer again and Matomo detects the existing data.

But this only works if the database and the files are of the same version.


#7

I have already generated my desired config file for the latest matomo version. But the database is empty for now and I need to migrate all the data to the new database. However I was concerned that Matomo might not work/would not recognise with the old database tables etc due to conflicts. If there are no conflicts then I will migrate this way.


#8

When the migration completes there will be still 2 important things to do. Update the database and archive the reports (since during the migration I will move only the raw data). Which should be done first? Should I run the updater first or the archiver? Does it make any difference?


(Lukas Winkler) #9

I’d recommend you to fully upgrade the Matomo instance before running the archiver.


#10

Hello Lucas,

Thanks for quickly answering my question. I am updating the database right now but it takes quite a while (already 2 hours in and I think I am not even in the middle).

I have another quick question. I ignored all the piwik_archive_* tables when creating the dump file. However, I noticed that the table sizes on the new database have a huge difference, especially on the table piwik_log_action. On the first server this table was 5GB in size. On the new server, after importing the dump file, the size is 25GB. Other tables have different sizes too, mainly piwik_log_link_visit_action and piwik_log_visit, but still not that much of a difference.

Any idea explanation why this might have happened?


(Lukas Winkler) #11

I’m sorry, but I’m not a huge database expert and have no idea why this could be.


#12

Matomo upgrade (from terminal) is still running. However I get no indication that it is indeed still running or maybe was interrupted. It’s 3 hours now in the same SQL command and it is not even in the largest of the tables. If it is running then I can wait, however how do I know that it is running without any issues?

Even in my matomo hostname there is no indication that the upgrade process is being executed, since I get prompted to run the upgrade (although from the terminal is it supposed to run already).

Is there a possible guess or indication about how long will the update of a 151GB database take?