What is the best way to purge old data if it has never been run in 12 years?

We have never activated the purging of old data before and just run our first archiving task in 12 years. Our database is over 20G in size, and we would like to purge everything that is older than 3 years.

I see the options in the UI to configure automatic purging and see I can schedule it to run daily, weekly or monthly, but I’m afraid it could take too long and timeout for the first run since we have too much data.

The help for the core:purge-old-archive-data console command is a bit confusing. Let’s say I want to delete data in multiple stages (chunks) so it’s more manageable, how should I specify the dates? The description for the parameter refers to months to purge, but then it shows a full date in the example, and referers to the date “from” which to purge.

For example, if I would like to delete 1 year of data per pass starting with the oldest first, how would I specify the date in the console command?

1 Like

I’m not sure if you still need help with this, but I came across this question while working through my own storage issues & thought I’d share what I learned in case it’s helpful to anyone else.

I agree that the date format is a bit too ambiguous in the documentation, the best info I could find was from a FAQ page:

./console database:optimize-archive-tables last2
./console database:optimize-archive-tables january

(Last 2 what? Days, weeks, months, years? Which January? Why only 2 examples? etc.)

But after some trial & error, I figured out at least some of the format:

./console database:optimize-archive-tables 2020
./console database:optimize-archive-tables january-2020
./console database:optimize-archive-tables october-2022

Still a little confusing, because everything else in Matomo uses the YYYY-MM-DD (or at least YYYY-MM) format, but at least it’s something! Not sure why they did it that way, it might be that the tool is only supposed to be used for months or something, not sure. :person_shrugging:

1 Like

Created: