Clean DB Mysql

Jérôme2 years ago

Hello everyone, do you have a doc or method to clean the database?

My goal is for example to keep only the routes over 1 year and to delete the old routes.

What table is it?

What is the command to run?

Thanks in advance !

jay2 years ago

login to mysql

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 180 day);
Anton Tananaev2 years ago

We have a documentation specifically for this:

https://www.traccar.org/clear-history/

Jérôme2 years ago

Hello, thank you for your feedback.

I don't want automation, I'm really looking for a tutorial / explanation to do it manually please.

Thanks

Anton Tananaev2 years ago

You don't have to automate it if you don't want. You can do it manually using the information provided on that page.

Jérôme2 years ago

Ok so it's fine in:

tc_positions?

Possible to have the command to execute to keep 1 year?

Thanks

Juan Sánchez2 years ago

You only have to modify the query provided…

login to mysql

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 365 day);
Jérôme2 years ago

Thx !!!

Marka year ago

https://www.traccar.org/clear-history/
Which traccar versions does this documentation apply to?
I ran the script on 4.11. It removes the data from the tc_positions table but overloads the server and won't finish. I have to kill it.

Anton Tananaeva year ago

It applies to the latest version and maybe for some recent versions, but you have to double check yourself before using it.