teslamate-org / teslamate

A self-hosted data logger for your Tesla 🚘
https://docs.teslamate.org
MIT License
5.75k stars 715 forks source link

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

Closed jamietudor closed 2 weeks ago

jamietudor commented 1 year ago

Is there an existing issue for this?

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

WengHaHa commented 1 year ago

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.

jamietudor commented 1 year ago

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.

kahobusiness commented 8 months ago

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)
jamietudor commented 8 months ago

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.

JakobLichterfeld commented 7 months ago

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

brianmay commented 7 months ago

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.

JakobLichterfeld commented 7 months ago

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

brianmay commented 7 months ago

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 commented 5 months ago

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.

henryhm0 commented 1 month ago

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

github-actions[bot] commented 3 weeks ago

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.