Blog Post

Backing up the Teslamate Database

,

I was worried about some of my data, so I wanted to be sure I had a backup of my Teslamate system. This post covers the config I’d added and how I backed things up.

This is part of a series that covers my experience with a Tesla Model Y.

The Backup Volume

In my Teslamate docker-compose file, I had added a backup volume some time ago. My config section looks like this:

2023-12-19 15_02_56-docker-compose.yml - PublicDocuments - Visual Studio Code

For this database container, I’d added the volumes for data and explicitly set a location that maps from a folder on my e: drive to a folder called backup in the postgresql location inside the container.

This ensures I can easily find my PostgreSQL backup file if I need it, which I hope I never do, but you never know.

Once this is set up, you can restart your container and the folder is mapped.

Running the Backup

There are instructions on the Teslamate Docs site, but I kept getting errors. I think some of those were because I was on docker compose v1, but I didn’t want to update without a backup.

So.

I used this code to connect to the container.

docker exec -ti teslamate_database_1 /bin/bash

Next, I ran this to backup the database.

pg_dump -U teslamate teslamate > backup/teslamate_20231219.bck

As you can see, it worked.

2023-12-19 14_55_16-Custom Selection

And I had a backup file in my folder.

2023-12-19 15_14_52-backup

Now to upgrade things.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating