Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

TeslaMate [megathread]

This site may earn commission on affiliate links.
If it works when running the script manually but not when the cron job runs it, it could be a permissions issue. There's a good chance that the cron job is running as a user that doesn't have permission to access the folder where are trying to copy the backup file.
I’ve deleted the old cron job and recreated the it under sudo -i as @DaveW suggested.

I’ll report back tomorrow...
 
  • Like
Reactions: DaveW
Not really, I just like something in life to look forward to ;)

I’ve edited the cron to run an 1425, it did, and the file was saved on the Pi and Google drive. Now re-edited to run daily at 0200.

Fingers crossed...

Sounds promising! I think as Malaromane was saying, this is likely a permissions issue. Hopefully it's now been setup with the root privileges it'll now work again, why it stopped again is another matter :)
 
  • Like
Reactions: Roy W.
Suspect the error you are getting is because the docker container is already running. Instead, try:

Code:
docker-compose down
docker-compose pull
docker-compose up -d

This should update both TeslaMate and Grafana to the latest versions. Suggest doing a backup first before upgrading.

Thanks @Melved, I appreciate the input. Unfortunately it didn't work for me & I need more help...Please? I can really only confirm that Teslamate is continuing to run fine on my pi. The following is my session and what I am getting when I SS into my pi with Putty. I started off trying to run the backup, that didn't work, then I tried to run the update, that didn't work. Then I tried to see the help file, at least that seemed to have worked, but is useless for me. (And yes I did actually use some DOS commands in there as it is all that is left that I know how to do).:

Code:
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Oct 19 03:15:40 2020 from 192.168.1.13
pi@raspberrypi:~ $ docker-compose exec -T database pg_dump -U teslamate teslamate > /backuplocation/teslamate.bck
-bash: /backuplocation/teslamate.bck: No such file or directory
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ dir
docker-compose.yml  -v
pi@raspberrypi:~ $ docker-compose exec -T database pg_dump -U teslamate teslamate
ERROR: No such service: database
pi@raspberrypi:~ $ docker-compose pull
Pulling teslamate ...
Pulling db        ...
Pulling grafana   ...
Pulling mosquitto ...

ERROR: for teslamate  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for mosquitto  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for grafana  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for db  ('Connection aborted.', PermissionError(13, 'Permission denied'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ cd..
-bash: cd..: command not found
pi@raspberrypi:~ $ dir
docker-compose.yml  -v
pi@raspberrypi:~ $ list
-bash: list: command not found
pi@raspberrypi:~ $ docker-compose -h
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file
                              (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name
                              (default: directory name)
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --no-ansi                   Do not print ANSI control characters
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the
                              name specified in the client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert deploy
                              keys in v3 files to their non-Swarm equivalent

Commands:
  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose pull
Pulling teslamate ...
Pulling db        ...
Pulling grafana   ...
Pulling mosquitto ...

ERROR: for teslamate  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for grafana  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for db  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for mosquitto  ('Connection aborted.', PermissionError(13, 'Permission denied'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $
 
Thanks @Melved, I appreciate the input. Unfortunately it didn't work for me & I need more help...Please? I can really only confirm that Teslamate is continuing to run fine on my pi. The following is my session and what I am getting when I SS into my pi with Putty. I started off trying to run the backup, that didn't work, then I tried to run the update, that didn't work. Then I tried to see the help file, at least that seemed to have worked, but is useless for me. (And yes I did actually use some DOS commands in there as it is all that is left that I know how to do).:

Code:
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Oct 19 03:15:40 2020 from 192.168.1.13
pi@raspberrypi:~ $ docker-compose exec -T database pg_dump -U teslamate teslamate > /backuplocation/teslamate.bck
-bash: /backuplocation/teslamate.bck: No such file or directory
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ dir
docker-compose.yml  -v
pi@raspberrypi:~ $ docker-compose exec -T database pg_dump -U teslamate teslamate
ERROR: No such service: database
pi@raspberrypi:~ $ docker-compose pull
Pulling teslamate ...
Pulling db        ...
Pulling grafana   ...
Pulling mosquitto ...

ERROR: for teslamate  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for mosquitto  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for grafana  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for db  ('Connection aborted.', PermissionError(13, 'Permission denied'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ cd..
-bash: cd..: command not found
pi@raspberrypi:~ $ dir
docker-compose.yml  -v
pi@raspberrypi:~ $ list
-bash: list: command not found
pi@raspberrypi:~ $ docker-compose -h
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file
                              (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name
                              (default: directory name)
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --no-ansi                   Do not print ANSI control characters
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the
                              name specified in the client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert deploy
                              keys in v3 files to their non-Swarm equivalent

Commands:
  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose pull
Pulling teslamate ...
Pulling db        ...
Pulling grafana   ...
Pulling mosquitto ...

ERROR: for teslamate  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for grafana  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for db  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for mosquitto  ('Connection aborted.', PermissionError(13, 'Permission denied'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $

Sounds like it could be a permission issue. Check that the pi user is in the docker group by running the following: groups
If you don't see docker in the reply, you will need to add the user to the group, if it exists, by running the below:

Code:
sudo groupadd docker
sudo usermod -aG docker $(whoami)

You may have to log out of the pi and ssh back in again for it to work then run the following to see if that worked: docker images
If that still doesn't work, you may need to install docker.
 
  • Like
Reactions: Roy W.
Thanks @Melved, I appreciate the input. Unfortunately it didn't work for me & I need more help...Please? I can really only confirm that Teslamate is continuing to run fine on my pi. The following is my session and what I am getting when I SS into my pi with Putty. I started off trying to run the backup, that didn't work, then I tried to run the update, that didn't work. Then I tried to see the help file, at least that seemed to have worked, but is useless for me. (And yes I did actually use some DOS commands in there as it is all that is left that I know how to do).:

Code:
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Oct 19 03:15:40 2020 from 192.168.1.13
pi@raspberrypi:~ $ docker-compose exec -T database pg_dump -U teslamate teslamate > /backuplocation/teslamate.bck
-bash: /backuplocation/teslamate.bck: No such file or directory
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ dir
docker-compose.yml  -v
pi@raspberrypi:~ $ docker-compose exec -T database pg_dump -U teslamate teslamate
ERROR: No such service: database
pi@raspberrypi:~ $ docker-compose pull
Pulling teslamate ...
Pulling db        ...
Pulling grafana   ...
Pulling mosquitto ...

ERROR: for teslamate  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for mosquitto  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for grafana  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for db  ('Connection aborted.', PermissionError(13, 'Permission denied'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ cd..
-bash: cd..: command not found
pi@raspberrypi:~ $ dir
docker-compose.yml  -v
pi@raspberrypi:~ $ list
-bash: list: command not found
pi@raspberrypi:~ $ docker-compose -h
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file
                              (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name
                              (default: directory name)
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --no-ansi                   Do not print ANSI control characters
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the
                              name specified in the client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert deploy
                              keys in v3 files to their non-Swarm equivalent

Commands:
  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information
pi@raspberrypi:~ $ docker-compose down
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose pull
Pulling teslamate ...
Pulling db        ...
Pulling grafana   ...
Pulling mosquitto ...

ERROR: for teslamate  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for grafana  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for db  ('Connection aborted.', PermissionError(13, 'Permission denied'))

ERROR: for mosquitto  ('Connection aborted.', PermissionError(13, 'Permission denied'))
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $ docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
pi@raspberrypi:~ $

On the backup side of things, one of the errors is because you are using the default directory supplied in the example, you’ll need to specify something like /home/pi or whatever your setup is.

The other part of it might be because the database has a different name, I’ll have a proper look when I’m in my home office after the school run, hard to see everything properly on my phone :)

I think Spydaws suggestion of permissions is a good one, give that a whirl and report back
 
  • Like
Reactions: Roy W.
Sounds like it could be a permission issue. Check that the pi user is in the docker group by running the following: groups
If you don't see docker in the reply, you will need to add the user to the group, if it exists, by running the below:

Code:
sudo groupadd docker
sudo usermod -aG docker $(whoami)

You may have to log out of the pi and ssh back in again for it to work then run the following to see if that worked: docker images
If that still doesn't work, you may need to install docker.

Thank you@Spydaw & @Melved. It told me that the group docker was already existing after I typed "sudo groupadd docker". So I tried
"sudo usermod -aG docker $(whoami)" & I still got an error. But then I logged out, logged back in, and used the lines
"
docker-compose down
docker-compose pull
docker-compose up -d", and they seem to have worked this time. I can now confirm I am running 1.20.0. Now I have to see about learning to properly backing this thing up. I suppose it was a bit risky this way but I couldn't get the backup or the update to actually update. Thanks again.....
 
  • Like
Reactions: Spydaw
Thank you@Spydaw & @Melved. It told me that the group docker was already existing after I typed "sudo groupadd docker". So I tried
"sudo usermod -aG docker $(whoami)" & I still got an error. But then I logged out, logged back in, and used the lines
"
docker-compose down
docker-compose pull
docker-compose up -d", and they seem to have worked this time. I can now confirm I am running 1.20.0. Now I have to see about learning to properly backing this thing up. I suppose it was a bit risky this way but I couldn't get the backup or the update to actually update. Thanks again.....

That makes sense, I think it says once you change the permissions (with the second statement) that you need to login for it to take affect.

I've put something together for an automated backup to Google Drive if that helps?

How to perform an automated TeslaMate backup to Google Drive
 
Stranger and stranger...

So, this morning I’ve got an automated backup. :D

The cron job is this:

* 2 * * * /home/pi/tmbackup/tmbackup.sh

but the files on both the Pi and Google drive are timed at 0259!

So it worked, but why is the time so late? A manual backup and Google upload takes 3 or 4 minutes.
 
Stranger and stranger...

So, this morning I’ve got an automated backup. :D

The cron job is this:

* 2 * * * /home/pi/tmbackup/tmbackup.sh

but the files on both the Pi and Google drive are timed at 0259!

So it worked, but why is the time so late? A manual backup and Google upload takes 3 or 4 minutes.

Well I'm glad it's working, but the timing I'm not sure on. Just checked mine and it's 4am on the dot! (only a 59mb file though)
 
Well I'm glad it's working, but the timing I'm not sure on. Just checked mine and it's 4am on the dot! (only a 59mb file though)
I’m glad you’re puzzled too :) My file is now 138MB, but all the previous ones that worked were at 3am, as per your example cron. I changed it to 2am just in case something funny was happening at my end at 3am to stop it working. At least it’s working now! Thanks for all your help @DaveW
 
Mine are at 3am after following your guide. Wonder if it's a UTC/BST issue?

Good point, will see if mine change post 25th of October :)

I’m glad you’re puzzled too :) My file is now 138MB, but all the previous ones that worked were at 3am, as per your example cron. I changed it to 2am just in case something funny was happening at my end at 3am to stop it working. At least it’s working now! Thanks for all your help @DaveW

Wonder at what point it's worth changing the backup script to zip up / compress the file too, save some space and time to upload.

Someone posted in here a while back on what to do, I'll revisit at some point and update the guide again with how to do that as an option (and how to unpack it after).

Glad it's working again though Roy
 
  • Like
Reactions: Roy W.
My GCP seems to be more or less stable at the moment. Looking back at the history over the past 7 days it seems to have had a live connection for all of it. There is a section of "offline" which lasted about a day but I wasn't driving during it anyway and the same section shows as offline on my Synology instance too (which is what i've been using as my primary source since GCP starting getting blocked) - I think occasionally it just shows as offline rather than sleeping for whatever reason.

If your car is showing as unavailable you may need to wake it first and then look at it in teslamate in order for it to realise it is available again?
 
I now have Teslamate running on a server hosted by Vultr (thought I'd avoid the big boys - just in case).

The process of restoring the data from my self hosted Pi instance was a pain though. Used the instructions here:
Backup and Restore | TeslaMate

This line of sql would fail:

Code:
 AS 'SELECT public.cube(public.cube(public.cube(public.earth()*cos(radians(\$1))*cos(radians(\$2))),public.earth()*cos(radians(\$1))*sin(radians(\$2))),public.earth()*sin(radians(\$1)))::public.earth';

Had to change to:

Code:
 AS 'SELECT public.cube(public.cube(public.cube(public.earth()*cos(radians($1))*cos(radians($2))),public.earth()*cos(radians($1))*sin(radians($2))),public.earth()*sin(radians($1)))::public.earth';

Not sure if it's an error in the docs or something pertaining to my environment, anyway, all done now.

It's nice to have it hosted, to be able to access it from the car's browser and also for it to be secure (htpasswd). Also nice to have the option to backup the server, rather than just the data.

Probably time to cancel my TeslaFi subscription and find an alternative use for the Pi.