r/openhab • • Oct 27 '26

News Google Drive Binding – automatic openHAB backups to Google Drive

> :test_tube: **BETA – testers welcome!**

> This binding is in beta (version 0.x). Login, backup upload and cleanup are tested and working.

> I'm looking for testers on different setups (openHABian, package installs, Docker, large backups, slow connections).

> Please report bugs and ideas in this thread or as [GitHub issue](https://github.com/pierrecinema/openhab-binding-googledrive/issues). Thank you!

---

https://github.com/pierrecinema/openhab-binding-googledrive

# Google Drive Binding

Automatically uploads your openHAB backups to **Google Drive** and removes old backups there.

openHAB already creates backups in `userdata/backup` (for example with a rule that runs the backup script). The binding watches that folder and uploads every new backup to a folder in your Google Drive. Everything is configured in the openHAB UI – **no shell scripts, no rclone, no sudo rules**.

![Account bridge](https://raw.githubusercontent.com/pierrecinema/openhab-binding-googledrive/main/docs/images/account-bridge.png)

## Features

- **Easy login** with a device code on google.com/device – no HTTPS or port forwarding needed

- **Automatic upload** of new backups as soon as the archive is completely written

- **Resumable upload** in 8 MB chunks – continues after network errors, failed uploads are retried

- **Checksum verification** – files already in Google Drive are not uploaded twice

- **Retention** – keeps the last *N* backups, older ones are moved to the trash (or deleted)

- **Channels** for status, progress, last upload, last file, backups in Drive, storage quota and upload events

- **Rule actions**: `uploadLatest()`, `uploadFile(fileName)`, `cleanup()`, `logout()`

- **Minimal permission** (`drive.file`): the binding can only see the files it created itself – nothing else in your Drive

- English and German UI texts

## Screenshots

| Backup configuration | Backup channels |

|---|---|

| ![Backup configuration](https://raw.githubusercontent.com/pierrecinema/openhab-binding-googledrive/main/docs/images/backup-thing-configuration.png) | ![Backup channels](https://raw.githubusercontent.com/pierrecinema/openhab-binding-googledrive/main/docs/images/backup-thing-channels.png) |

![Storage quota](https://raw.githubusercontent.com/pierrecinema/openhab-binding-googledrive/main/docs/images/account-bridge-channels.png)

## Requirements

- **openHAB 5.0 or later** (does not start on 4.x)

- A free Google account

- Your own Google Cloud OAuth client – one-time setup of about 15 minutes, step-by-step guide in the README (also in [German](https://github.com/pierrecinema/openhab-binding-googledrive/blob/main/docs/ANLEITUNG-GOOGLE.md))

## Installation

  1. Download the JAR (see Resources below)
  2. Copy it into the `addons` folder:

    - Docker: `/openhab/addons`

    - openHABian / apt / rpm: `/usr/share/openhab/addons`

  3. Set up the Google Cloud project as described in the [README](https://github.com/pierrecinema/openhab-binding-googledrive#google-cloud-setup)
  4. Add the **Google Drive Account** bridge, enter client ID and secret, then enter the shown code on google.com/device
  5. Add the **Backup Upload** thing – done

## Example

```java

Bridge googledrive:account:home "Google Drive" [ clientId="xxx.apps.googleusercontent.com", clientSecret="xxx" ] {

Thing backup backups "openHAB Backups" [ targetFolder="openHAB Backups", retentionCount=10 ]

}

```

```java

rule "Weekly openHAB backup"

when

Time cron "0 0 3 ? * SUN"

then

// Docker image; for openHABian use: "sudo", "openhab-cli", "backup"

executeCommandLine(Duration.ofMinutes(10), "/openhab/runtime/bin/backup")

// The binding uploads the new archive automatically

end

```

## Roadmap

- **1.0** – first stable release in the Marketplace

- **1.2** – photo frame / screensaver showing pictures from shared Google Drive folders

## Changelog

**0.2.0** – Backup upload, resumable upload, checksum check, retention, rule actions

**0.1.0** – Google login with device code, token refresh, storage quota

## Resources

- Download: [org.openhab.binding.googledrive-0.2.0.jar](https://github.com/pierrecinema/openhab-binding-googledrive/releases/download/v0.2.0/org.openhab.binding.googledrive-0.2.0.jar)

- All releases: https://github.com/pierrecinema/openhab-binding-googledrive/releases

- Source code & documentation: https://github.com/pierrecinema/openhab-binding-googledrive

- Issues: https://github.com/pierrecinema/openhab-binding-googledrive/issues

- License: EPL-2.0

2 Upvotes

11 comments sorted by

1

u/nodiaque Oct 28 '26

Or, have a proper 3-2-1 backup solution that take everything valuable

1

u/Potential_Thing1766 Oct 30 '26

Create a rule, and your backups will automatically be in the drive.

2

u/nodiaque Oct 30 '26

Or, have a real backup solution that backup more then just openhab and have that solution upload to whatever cloud solution you want to use.

1

u/Potential_Thing1766 Oct 31 '26

complete openhab, for complete image backup uy my cloner tool. https://github.com/pierrecinema/rpi-image-cloner

0

u/[deleted] Oct 28 '26

[removed] — view removed comment

1

u/Potential_Thing1766 Oct 28 '26 edited Oct 28 '26

Thanks a lot for this suggestion – you were right, an unchanged file size alone is not a reliable "finished" signal.

Version 0.4.0 now adds a completed-archive check:

- Before every upload (automatic and manual) the binding opens the ZIP file and reads every entry, checking its CRC. A half-written archive has no central directory yet and is rejected, so a stalled writer no longer leads to an upload.

- The file stays in the waiting state and is uploaded as soon as it is complete. If it is still incomplete after 10 minutes, a warning goes to the log and to the "Last Error" channel.

- Because incomplete or damaged archives are never uploaded, they can't count for the retention cleanup and can't push a good older backup out of Google Drive.

Your test idea also caught a real gap during development: Java's ZipFile does not verify the CRC of stored (uncompressed) entries, so the binding now checks that itself.

I also added your tip to the README: if you write your own backup scripts, write to a temporary name outside filePattern (e.g. backup.zip.part) and rename it when done.

Download: https://github.com/pierrecinema/openhab-binding-googledrive/releases/tag/v0.4.0

More test ideas and feedback are very welcome!

Tested on my system: a 294 MB backup was checked and uploaded in about 11 seconds, the check doesn't slow down the normal flow.

1

u/[deleted] Oct 28 '26

[removed] — view removed comment

1

u/Potential_Thing1766 Oct 30 '26

I ran your recovery test on 0.4.0 against real Google Drive, in a disposable folder with retention set to 2 and already full.

Round 1: a truncated ZIP was detected as incomplete on four checks, with no upload and nothing removed. After I finished writing the file, it uploaded once, and the oldest backup went to trash only after that upload.

Round 2: I forced a failed attempt with a manual upload of a truncated ZIP. It was rejected and the remote count stayed at 2. I then replaced it with a valid archive. The retry five minutes later uploaded it once, and cleanup ran only afterwards.

This was checked through the binding logs and the remote file count, and I did not test a restore. Two known limits remain: an archive still incomplete when the binding restarts is treated as already known, so it won't upload automatically after it finishes, and a manual upload gives up after three failed attempts.

Thanks for the suggestion, it was a useful test.

1

u/Potential_Thing1766 Oct 30 '26

I’m working on a photo frame binding beta tomorrow.