Repository navigation
Description
Summary
Add optional Google Drive integration so database backups can be automatically uploaded off-device on a schedule, not just written to the local `backups/` folder. This is a natural follow-on to #120 (Backup Management & History UI) — that issue makes local backups visible and restorable; this one gets a copy off the machine so a lost/stolen/failed device doesn't mean lost backups.
Why
Local backups in `app.getPath('userData')/backups/` protect against DB corruption but not against device loss, theft, or disk failure. Restaurants running a single POS machine have no offsite copy today.
Proposed Enhancement
- Add a "Google Drive" section under Settings > Integrations (alongside the existing Cloud tab introduced in the offline-first audit).
- OAuth connect flow scoped to `drive.file` only (the app should only ever see/manage files it created — not full Drive access).
- Configurable backup frequency (e.g. daily/weekly) using the existing backup mechanism, uploading the resulting `.db` file to a dedicated app folder in the user's Drive.
- Manual "Back up to Drive now" action in addition to the schedule.
- Retention/rotation setting (e.g. keep last N backups) so Drive storage doesn't grow unbounded.
- Surface last successful Drive backup time/status somewhere visible (Settings, or the Backup History table from Feature: Backup Management & History UI #120).
Security & Offline-First Requirements
This must follow the same explicit opt-in pattern established in the recent offline-first audit (see the "Explicit Cloud Opt-in" work for the Cloud Services tab) — not the old zero-touch behavior that was deliberately removed:
- Google Drive sync must be off by default and require explicit user opt-in, same as cloud services.
- No connection attempt or background request to Google APIs until the owner explicitly connects their account.
- OAuth tokens must be stored using OS-level secure storage (matching how other secrets are handled in this app), never in plain text in the SQLite DB.
- Only the `drive.file` scope (least privilege) — never request full Drive read/write access.
- Disconnecting Google Drive in settings should revoke the stored token, not just hide the UI.
- Backups uploaded to Drive should be the same encrypted/redacted artifact produced by the existing backup flow — no separate export path that might skip existing redaction (see the `/api/db/export` secret-redaction fix).
Relationship to other issues
- Builds on Feature: Backup Management & History UI #120 (Backup Management & History UI) — ideally the Drive upload status shows in the same backup history table.
- Should reuse the existing backup creation code path (`createBackup`) rather than introduce a second backup mechanism.
Out of scope for v1
- Other providers (Dropbox, OneDrive, S3) — Drive only for the first iteration.
- Automatic restore-from-Drive on a fresh install (manual download + restore is fine for v1).
Approved v1 delivery context
The approved v1 scope is app-owned visible Drive storage with one Google account per installation, owner-only Drive actions, PKCE OAuth with OS-backed token storage, configurable destination, startup/scheduled/manual online backups, manual backups retained indefinitely, automatic retention defaulting to seven with older automatic files moved to Drive Trash, offline/retry handling, and guarded in-app restore with schema/app-version checks. Existing local backup behavior remains unchanged.
Implementation status: the service, authenticated settings routes, owner-only UI, restore safeguards, translations, and setup documentation are implemented in the delivery worktree and undergoing focused validation. The PR and captain-testing link will be added in a follow-up comment once a real PR URL exists; the issue remains unmerged for captain testing.
Audit and plan context: `data/flocafe-google-drive-backup-audit-scout/report.md` and `data/flocafe-google-drive-implementation-plan-r1/report.md` in the delivery workspace; maintainer-facing setup notes are tracked in docs/google-drive-setup.md.
Activity
feat(settings): Backup Management & History UI (#120)
Add Google Drive integration for automated DB backups (FreeOpenSource…
docs: refresh README against current Electron/roadmap/feature state