Database Full

mrdctau9 years ago

What happens when the database is full?

Is there some way to delete old data?

I'm running Traccar Server on a Raspberry Pi with a 8gb SD card with two GPS trackers. Roughly how long until my database will be full?

aspero9 years ago

Hi,

It depends on how much data you store and how often you collect it - this can be set by your trackers.
I suggest you check the sd card after i.e. 3 months and you will know the answer how long it will last.
If you have the option to put trackers into sleep mode when the vehicle doesn't move, you will increase this capacity a lot.

Anyway, 8GB is a lot of space! You may also have a look here:
http://dba.stackexchange.com/questions/46069/how-to-estimate-predict-data-size-and-index-size-of-a-table-in-mysql

Bartek.

Anton Tananaev9 years ago

If you are using MySQL database, it should be fairly easy to write a script that would remove old data.

mrdctau9 years ago

My two trackers only upload data when they are the move and do so every 30 seconds in that state. One is used infrequently (perhaps 15 minutes per day) and the other probably averages about 60 minutes per day but does a couple of longer trips most weekends.

I am using the latest version 3.1 which I believe doesn't use the MySQL database.

I wouldn't know where to start to write a script. Is there a command line instruction I could type in when I've made an SSH connection to my Traccar Server? When can I look in the directory on my Traccar Server to see the size of the database?

Anton Tananaev9 years ago

If you are using default H2 database, it's more complicated. It's an embedded database, so there is no way to connect to it from two different processes.

I would recommend to move to MySQL database.

diggah9 years ago

In MySQL you can use :

DELETE * from position WHERE deviceTime < (NOW() - INTERVAL 90 day);

mrdctau9 years ago

I don't really have much choice but to use the default H2 Database because I have absolutely no idea how to create or maintain a MySQL database. What happens when the H2 Database gets full? I guess I can just do a fresh reinstall of Traccar unless someone has a better idea.

Anton Tananaev9 years ago

You don't really need to know much about MySQL if you don't manage massive amounts of data.

As for H2, it won't get full. It will just grow and become slower over time until it reaches the storage limit at which point it would probably crash.

VipTecnologias6 years ago

DELETE FROM events WHERE serverTime < 2018-01-01 (NOW(), INTERVAL -1 MONTH);

response in SQL Server:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(NOW(), INTERVAL -1 MONTH)' at line 1

or
DELETE * from position WHERE deviceTime < (NOW() - INTERVAL 90 day);

response in SQL Server:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* from position WHERE deviceTime < (NOW() - INTERVAL 90 day)' at line 1