Data Recovery Strategy: Merging Position Data Between Two Traccar Instances

geo21 days ago

Data Recovery Strategy: Merging Position Data Between Two Traccar Instances

Hello,

I'm facing an hipotetical data continuity challenge and would appreciate guidance on the best approach to resolve it.

Scenario:

  1. Original VPS (Server A) with months of tracking history failed on Monday due to provider issues
  2. Set up new VPS (Server B) with fresh Traccar instance on Monday to maintain service
  3. Original server (A) came back online on Wednesday
  4. Want to move devices back to Server A, but missing Tuesday's data

Current situation:

  • Both servers have different database IDs for devices and positions
  • Only IMEI numbers match between servers
  • Need to recover/transfer Tuesday's tracking data from Server B to Server A
  • Direct table copying not feasible due to different ID structures

Questions:

  1. Is there a way to forward/replay position data from Server B to Server A?
  2. Can we use device logs as a source to forward historical positions?
  3. What's the recommended approach to merge position data while maintaining data integrity?

obviously I am referring only to GPS potions, not to devices and users created or deleted

Any guidance on the best practice for this scenario would be greatly appreciated.

Kaloyan Kanev21 days ago

What DB are you use, for how many device you are talking about ?
If you are use MySQL DB, you can make it manually, device by device, one by one.
Go to phpmyadmin or use HeidiSQL, make query to select all data from tc_position for some deviceId, export the data as .sql, after that open the file, rename the old deviceId with the new one which is in the new server, save the file and import it in the new server in tc_positions table.
Repeat the procedure with all devices which you want to move in the new server.

geo21 days ago

I don't see how it would work, imagine first having to do it for about 200 or more devices, and if you copy the positions from the new server, the position ids will be different, so they won't be able to be seen in the replay logs, which is the idea, integrate the history not received into the main server

Kaloyan Kanev21 days ago

Of course it will work, when you will make some report or replay Traccar makes query from tc_positions, selecting all positions where deviceId is selected (in the range of the time which you selected). No matter the id of position, just this positionId must to be connected with the right deviceId.
Try with one car and you will see the result.

Anton Tananaev21 days ago

You have to update the device id to match before you import the data.

carlock12 days ago

Greetings, Anton, I have a question, wasn't this tool for cases like this? to resend the old logs? https://github.com/traccar/traccar/blob/master/tools/recover.py

Anton Tananaev12 days ago

That tool hasn't been updated for a while. And it's much slower than copying database records directly.