Jul 282020
 

Anyone who owns a Garmin watch, bike computer or other activity logging computer can’t have failed to notice the 3 day outage on Garmin Connect over the weekend of 24-26th July 2020. Being denied access to a large portion of my data made me swiftly evaluate my (lack of) backup strategy. I expect it also forced quite a lot of people to dig out their USB cables to upload activities to Strava.

I have most of the more recent activity data (bike rides and walks) still on my devices, but a whole year’s worth (June 2018 to July 2019) was not backed up anywhere else at all. So I vowed to rectify this grievous evil the moment Garmin Connect came back online, which happened on Monday 27th (the day of writing this).

Why the Urgency?

Well the rumours on the internet say that Garmin was a victim of ransomware. If a tech company that large can get taken down, anyone can. So any data you care about, you should have control of (or at least a backup copy under your control).

It looked as if I was going to have to struggle with something like 400 individual activities, downloading each .fit or .tcx file separately and manually. YUCK! How boring, and what a waste of time. If only someone had written some code to automate this for us. Worth a look I suppose? So I looked.

And I found GarminExport on Github.

https://github.com/petergardfjall/garminexport

Looks Promising

It looked like it might do the trick, so I installed it on a Raspberry Pi 4 with…

pip3 install garminexport

…then add home/pi/.local/bin to the path by editing ~/.profile
nano ~/.profile

…and add this line at the end…
PATH=$PATH:home/pi/.local/bin

Then logout and log back in again to activate the changes.

Now Download Your Data

After that, the following command will download all your activities to a [new] directory called “activities” (or whatever you choose). You will need to change your_id_or_email to your Garmin Connect login ID. And you will also be asked for your password as a second step, so have that ready too.

garmin-backup --backup-dir=activities your_id_or_email --format fit

It took about 15 minutes to download all 844 of my activities as .fit files. I was mighty chuffed. I sftped them via my Mac to a portable USB drive, but left them still on the Pi too.

You can use the same command to do an incremental backup as well. garminexport will ignore any files it has already backed up in the specified directory.

Downloading TCX files from my Garmin Connect account

Downloading TCX files from my Garmin Connect account

Other Formats Too

If you prefer gpx or tcx files, you can change --format fit to e.g. --format tcx
If you omit the --format option it will download all available variants.

.fit are the original raw data files straight from the Garmin device. .tcx and .gpx are processed and in a different format. I found .tcx took slightly longer to download. But none of the files contain any of the notes you may have written on Garmin Connect. It would appear that you can’t back those up independently this way.

Can Now Complete My Strava Records

The added bonus here is that I now have all the files I need, should I wish to have a complete activity record on Strava or any other platform in the future. When you first sign up for Strava it allows a mass import from Connect, but only takes something like the 150 or 250 most recent activities. If you have more history than that and you want them all, you have to upload them yourself (in batches of <=25). Well at least now I have the files if I choose to do that. 400 / 25 is still a lot of iterations though. I wonder if anyone's written software to automate that process?

  5 Responses to “Back up your Garmin activity data on a Raspberry Pi”

  1. Hello Alex, great pleasure your e-mail, you thought my thoughts! Best regards.

  2. Thanks for the post. Am backing up my Garmin rides too now. I also did an export from Strava which does include a lot more info and photos taken. Do you know any self hosted projects that read the strava exports?

    • Not sure. I’ve been told Golden Cheetah can be used to bulk upload activities to Strava, but not sure if you can do it the other way round.

  3. Hello,

    I’m trying to backup but this happens:

    2020-08-03 21:06:39,299 [INFO] activities contains 0 backed up activities
    2020-08-03 21:06:39,299 [INFO] activities that aren’t backed up: 155
    2020-08-03 21:06:39,299 [INFO] backing up activity 3554668082 from 2019-04-14 09:04:10+00:00 (1 out of 155) …
    2020-08-03 21:06:39,299 [INFO] {get_activity_tcx}: attempt 1 …
    2020-08-03 21:06:39,525 [INFO] {get_activity_tcx}: waiting 1 seconds for next attempt
    2020-08-03 21:06:40,526 [INFO] {get_activity_tcx}: attempt 2 …
    2020-08-03 21:06:40,857 [INFO] {get_activity_tcx}: waiting 2 seconds for next attempt
    2020-08-03 21:06:42,859 [INFO] {get_activity_tcx}: attempt 3 …
    2020-08-03 21:06:43,113 [INFO] {get_activity_tcx}: waiting 4 seconds for next attempt
    2020-08-03 21:06:47,117 [INFO] {get_activity_tcx}: attempt 4 …
    2020-08-03 21:06:47,364 [INFO] {get_activity_tcx}: waiting 8 seconds for next attempt
    2020-08-03 21:06:55,372 [INFO] {get_activity_tcx}: attempt 5 …
    2020-08-03 21:06:56,118 [INFO] {get_activity_tcx}: waiting 16 seconds for next attempt
    2020-08-03 21:07:12,134 [INFO] {get_activity_tcx}: attempt 6 …
    2020-08-03 21:07:12,398 [INFO] {get_activity_tcx}: waiting 32 seconds for next attempt
    2020-08-03 21:07:44,430 [INFO] {get_activity_tcx}: attempt 7 …
    2020-08-03 21:07:44,672 [INFO] {get_activity_tcx}: waiting 64 seconds for next attempt
    2020-08-03 21:08:48,674 [INFO] {get_activity_tcx}: attempt 8 …
    2020-08-03 21:08:49,576 [ERROR] failed with exception: {}: gave up after get_activity_tcx failed attempt(s)

    Maybe some problem on Garmin side? Or I’m doing something wrong?

    • Doesn’t look like anything wrong on your side unless your internet connection went down after the initial handshake?
      Most likely an issue at the Garmin end. Suggest to try again later.

Leave a Reply to alex Cancel reply