Is it possible to revert a logfile import?

Hi folks,

unfortunately, our trainee imported ten days from logfiles into an existing custommers site and now these ten days are a total mess.

Is there any way to revert this? - The data recorded by the site’s matomo-js should remain, so everything will be beautiful again.

Many thanks for any hint


You can try around with the GDPR tool to delete visits depending on some parameter (maybe you find one that only applies to log analytics imports) and invalidate and reprocess the reports.


Hi again,

I did not find a way to revert a logfile import, but instead a way how to clean all statistics of a site of several days and then use the replay-log import method to get the correct statistics of these days back.

  1. Grep all Loglines form the matomo Apache logfile for the given dates with the idsite Param of our corrupted site into a new file to use with the replay-log import method

  2. Delete not yet archived statistics data of the site for the given time-period + one day:
    php /srv/www/vhosts/piwik1mydomain.tld/htdocs/console core:delete-logs-data --dates=2020-09-01,2020-09-11 --idsite=27

  3. Create a database backup-dump of the archive tables for the given date-period, just for the case of errors:
    mysqldump --add-drop-table piwik1 piwik_archive_blob_2020_09 piwik_archive_numeric_2020_09 >> /srv/www/2020-09-16_piwik1_piwik_archive_blob_2020_09_piwik_archive_numeric_2020_09.sql

  4. Delete the correspondig entries from the archive tables:
    delete from piwik_archive_blob_2020_09 where idsite=27 and date1 BETWEEN ‘2020-09-01’ AND ‘2020-09-10’ and date2 BETWEEN ‘2020-09-01’ AND ‘2020-09-10’;
    delete from piwik_archive_numeric_2020_09 where idsite=27 and date1 BETWEEN ‘2020-09-01’ AND ‘2020-09-10’ and date2 BETWEEN ‘2020-09-01’ AND ‘2020-09-10’;

  5. Do the Matomo replay-log method:
    …/misc/log-analytics/ --url=https://piwik1.mydomain.tld --replay-tracking apache-matomo-replay-log.log

  6. Archive the imports…
    php /srv/www/vhosts/piwik1.mydomain.tld/htdocs/console core:archive --url=https://piwik1.mydomain.tld --force-all-websites

Maybe this also helps someone else

1 Like