teslamate icon indicating copy to clipboard operation
teslamate copied to clipboard

"Visited" map has lost visualization after backup and restore on a different machine

Open jamietudor opened this issue 2 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What happened?

I moved my Teslamate install from one Docker container on one server to another on another server using the instructions on the site about how to move.

All the data seems to have moved okay - I can see all my old data in the dashboards.

However, the map visualisation on the "Visited" dashboard which shows locations visited on a map has lost all the history. It's only got locations visited since I moved the data.

Expected Behavior

The map should show a visualisation of all historic data in the database.

Steps To Reproduce

View "Visited" dashboard: map shows locations visited since install was moved View "Locations" dashboard: over a year of drive history is present here.

Relevant log output

Last part of logs below - unsure if relevant

teslamate_1  | 2023-06-07 15:15:38.478 [error] GET https://owner-api.teslamotors.com/api/1/vehicles/1492932234725963 -> error: "socket closed" (33.956 ms)
teslamate_1  | 2023-06-07 15:15:38.479 [warning] TeslaApi.Error / socket closed
teslamate_1  | 2023-06-07 15:15:38.482 car_id=1 [error] Error / :unknown
teslamate_1  | 2023-06-07 15:15:50.084 [error] Vehicle Error: Vehicle is offline
teslamate_1  | 2023-06-07 15:16:08.668 car_id=1 [info] Start / :offline
teslamate_1  | 2023-06-07 15:16:08.724 car_id=1 [info] Disconnecting ...
teslamate_1  | 2023-06-07 15:28:42.734 [info] GET /
teslamate_1  | 2023-06-07 15:28:42.844 [info] Sent 200 in 110ms

Screenshots

Visited Map: visited

Example of a few drives from 6 months ago that aren't visualised:

drives

Additional data

Export of drives table from 2023-01-01 onwards

drives.csv

Type of installation

Docker

Version

v1.27.2

jamietudor avatar Jun 07 '23 15:06 jamietudor

Hello, although I am unable to provide effective assistance on this issue. But I am still very curious about how you moved a container belonging to one server to another server's container. I attempted to reinstall the container on another server, but I was unable to transfer the data in the Postgres database. I tried the method in https://docs.teslamate.org/docs/maintenance/backup_restore/ ,but it cannot succeed either. Sincerely need your solution, much love.

WengHaHa avatar Jun 10 '23 12:06 WengHaHa

I followed the document you linked to. I installed the Teslamate container on a new server in the normal way, stopped both the old and the new container, then ran the scripts on that page to backup the database from the old and restore to the new.

Apart from this visualisation issue which I'm experiencing, it worked first time with no issues.

jamietudor avatar Jun 12 '23 06:06 jamietudor

Hey, i think i just fixed this problem.

The method in https://docs.teslamate.org/docs/maintenance/backup_restore/ can't move the data of table positions . So we need to move it ourself.

if your original data still exist, please try:

  1. Backup positions data by : docker compose exec -T database pg_dump -U teslamate teslamate -t positions -F c > teslamate-positions.dat
  2. Resotre positions data to your new container by : docker compose exec -T database pg_restore -U teslamate -d teslamate -t positions teslamate-positions.dat (ps. I used pgAdmin to restore the data, and recommand)

kahobusiness avatar Dec 27 '23 02:12 kahobusiness

I actually bought a new Tesla so the old data is now gone. Good fix though, very useful if I need to move containers again.

jamietudor avatar Dec 28 '23 09:12 jamietudor

The method in https://docs.teslamate.org/docs/maintenance/backup_restore/ can't move the data of table positions . So we need to move it ourself.

if your original data still exist, please try:

  1. Backup positions data by : docker compose exec -T database pg_dump -U teslamate teslamate -t positions -F c > teslamate-positions.dat
  2. Resotre positions data to your new container by : docker compose exec -T database pg_restore -U teslamate -d teslamate -t positions teslamate-positions.dat (ps. I used pgAdmin to restore the data, and recommand)

If it's true that the position table is not backed up, we need to look into it. @brianmay @swiffer

JakobLichterfeld avatar Feb 07 '24 17:02 JakobLichterfeld

The data I get from the pg_dump command in the docs looks OK to me... But not really sure what I should be looking for.

brianmay avatar Feb 08 '24 00:02 brianmay

Same for me, but my visited dashboard only shows places I visited since my last restore

JakobLichterfeld avatar Feb 08 '24 07:02 JakobLichterfeld

I don't doubt there is a problem, but at loss to explain.

Sure that there are not any errors when restoring? Postfix does have strong relation constraints, if for example we tried to restore the positions entry and the corresponding car or drive was available (because the restore order was wrong), that would cause an error.

But in my dump the order looks fine.

I guess I should try to restore dump to a test database and see what happens.

brianmay avatar Feb 08 '24 09:02 brianmay

I just did a full backup and restore to a test database, and to me it looks like all the data is there in the positions table.

Wondering if somehow the car_id changed and got incremented for new data. But that doesn't make sense either, I would expect grafana to display every car.

brianmay avatar Mar 30 '24 06:03 brianmay

I have done back/restore multiple times without any issues.

henryhm0 avatar Jul 09 '24 12:07 henryhm0

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 09 '24 01:08 github-actions[bot]