Removing/Purging Old Tracking Data

Is there an established method to purge old tracking data? Example, we would want to delete all tracks for all units from X date prior...
Cheers.

Anton Tananaev6 years ago

Yes, there is a configuration option for that, but I would recommend to have some script outside of Traccar for that.

Slawek6 years ago
delete from tc_positions where servertime < DATE(NOW() - INTERVAL 180 day)
delete from tc_statistics where capturetime < DATE(NOW() - INTERVAL 180 day)
delete from tc_events where servertime < DATE(NOW() - INTERVAL 180 day)

Will delete all older than 180 days

EUROCAR6 years ago

Sorry for being a newbie. How to execute the above script? What works for me, I remotely connect to database via DBeaver and then I clear the heaviest tables, Events and Positions via truncate command. Unfortunately all data is gone after that. Tables start from scratch.

peteclyde5 years ago

Thanks Slawek - searched all over the forums trying to work out how to cull my database. There are a few posts on the topic but most of them are vague and don't help much.

I presume that your 3 queries are for phpmyadmin? I purged direct from the mysql command line and the only thing I had to add was the ; at the end of the query.

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 180 day);
delete from tc_statistics where capturetime < DATE(NOW() - INTERVAL 180 day);
delete from tc_events where servertime < DATE(NOW() - INTERVAL 180 day);

The <entry key='database.positionsHistoryDays'>180</entry> in the traccar.xml file didn't seem to do anything, which seems to be a consensus in a lot of the forum posts that I read.

Using command line mysql I managed to go from 1.6 gb database down to 53 mb.

Pete

yomeka3 years ago

Hi, I have a problem with the size of tc positions, it weighs 16G
and tried the following:

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 180 day);
delete from tc_statistics where capturetime < DATE(NOW() - INTERVAL 180 day);
delete from tc_events where servertime < DATE(NOW() - INTERVAL 180 day);

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