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. Thank you!


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

Features

  • Easy login with a device code on Anmelden – Google Konten – 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 Backup channels

Storage quota

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)

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
  4. Add the Google Drive Account bridge, enter client ID and secret, then enter the shown code on Anmelden – Google Konten
  5. Add the Backup Upload thing – done

Example

Bridge googledrive:account:home "Google Drive" [ clientId="xxx.apps.googleusercontent.com", clientSecret="xxx" ] {
    Thing backup backups "openHAB Backups" [ targetFolder="openHAB Backups", retentionCount=10 ]
}
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

Update: Google Drive Binding 0.4.0 is available :tada:

Download: org.openhab.binding.googledrive-0.4.0.jar
All releases: Releases · pierrecinema/openhab-binding-googledrive · GitHub

Update from an older version: delete the old JAR from the addons folder and copy the new one. Things, items and the Google login are kept.

Changelog

0.4.0 – safer backup detection

  • Completed-archive check: before every upload (automatic and manual) the ZIP file is opened and every entry is read and checked against its CRC
  • Half-written or damaged archives are not uploaded; the binding keeps waiting and warns after 10 minutes if a backup stays incomplete
  • Incomplete archives can no longer affect the retention cleanup in Google Drive
  • Tested with a real 294 MB backup: checked and uploaded in about 11 seconds

0.3.0 – keep N backups on the server

  • New setting Backups to Keep on Server: only the newest N backups stay in userdata/backup
  • Safety rule: a local backup is only deleted if it is in Google Drive or older than the newest backup in Google Drive – a backup that could not be uploaded yet is never deleted
  • New dashboard widget (MainUI card) with status, last upload, backups in Drive, storage bar and “Upload now” button – YAML in the repo and attached to every release

0.2.0 – backup upload

  • Automatic upload of new backups, resumable in 8 MB chunks
  • Checksum verification, no duplicate uploads
  • Retention: keeps the last N backups in Drive, older ones go to the trash (or are deleted)
  • Channels, trigger events and rule actions uploadLatest(), uploadFile(), cleanup()

0.1.0 – first version

Documentation

Feedback, bug reports and test ideas are very welcome – here or as GitHub issue. If no bigger problems show up, the next step is version 1.0 in the Add-on Marketplace.