To move Matomo from one server to another, you need to move all the Matomo files (the whole directory containing Matomo files), as well as the database to another MySQL server.

Follow these steps to migrate all Matomo service and data to another server

  1. Export your MySQL database in a file; you can use tools such as phpMyAdmin or mysqldump to do this. The simplest way to make a full copy of the MySQL database is to run the mysqldump command with this set of parameters: $ time mysqldump --extended-insert --no-autocommit --quick --single-transaction MATOMO_DATABASE_NAME -uMATOMO_DATABASE_USERNAME -p > matomo_backup_database.sql. If you use Matomo Cloud, then you can securely download your full database dump by contacting the Matomo Cloud Support team.

  2. We can then compress this backup before sending it to the backup server: $ tar zcf matomo-mysql-database-$(date +%Y-%m-%d-%H.%M.%S).sql.tar.gz matomo_backup_database.sql.

  3. Import the backed up database in your new server; you can use phpmyadmin to import the file that you previously created, or restore the DB backup by running the following command: $ time mysql MATOMO_DATABASE_NAME -uMATOMO_DATABASE_USERNAME -p < matomo_backup_database.sql. This should create more than a dozen Matomo tables in your database.

  4. Install Matomo in your new server. We recommend you install the exact same version as the one you are currently using. If you use a newer version, it is also likely to work. However, an automatic data migration to support the new Matomo version may take place in the new instance, and it may render the new server unusable until the migration finishes. Based on the size of the data and the new Matomo version, this could take minutes or hours.

  5. During the installation process, you will be asked to provide the MySQL server, login, password and table prefix. Specify the same table prefix (by default, “matomo_”). Matomo will detect that the tables are present in the database and all your existing websites and reports will be automatically detected. It will only work if you re-install the exact same version – see Which version of Matomo should I use?, and download the right version from the builds.piwik.org server.

  6. If the Matomo domain name has changed, you also need to change the Matomo JavaScript tags on all your tracked pages. For example, if Matomo was installed in piwik.example.org and you now installed it in piwik.example-different.com or example.org/piwik, you need to update the tags on all your websites’ pages.

  7. If you use the auto archiving cron, you will have to setup the cron script on the new server.

Note that during the operation, visits will not be tracked.

See also: How do I migrate a particular website in Matomo to a different Matomo installation?