How to back up Matomo in Docker (2026)

Matomo spreads its state across its MySQL and MariaDB databases and 2 data volumes on disk, plus compose and .env config. A backup that skips any layer will not restore cleanly. Dockstash auto-detects each layer, dumps the database from inside the container, and stores the lot off-site with restic.

What it stores

What Matomo stores

Compose servicesmatomo, mysql
Databases detectedmysql, mariadb
Data volumesmatomo_data (/var/www/html), db_data (/var/lib/mysql)
Config pathsdocker-compose.yml, .env, config/config.ini.php
Step by step

The backup plan

  1. Dump the MySQL database. Run mysqldump --all-databases --single-transaction inside the db container to capture visits, actions, and all reporting archives consistently — this is the bulk of Matomo data.
  2. Capture the Matomo files and config. Restic the matomo_data volume (plugins, GeoIP databases, custom logos) and config/config.ini.php which holds the database credentials and salt.
  3. Capture compose and .env. Restic docker-compose.yml and .env so the stack and database connection settings rebuild identically.

Restoring Matomo

Almost all Matomo data lives in MySQL, so the consistent dump is the core of the backup. Preserve the salt in config.ini.php or stored credentials and API tokens break after restore.

Back up Matomo in one click All guides

Last updated: July 2026

Frequently asked questions

Where does Matomo store its analytics data?

In MySQL/MariaDB — visits, actions, and pre-computed report archives. A consistent mysqldump --single-transaction captures the bulk of your Matomo data.

Do I need the file volume as well?

Yes, for plugins, GeoIP databases, custom assets, and config.ini.php. The database is the core, but config and plugins are needed for a clean restore.

What in config.ini.php matters?

The database credentials and the salt used for token generation. Restore it so API tokens and stored secrets remain valid.