Skip to content

rclone Google Drive service account fails to set shared drive during bootstrap

Bootstrapping an rclone remote for a Google Shared Drive using a service account (rclone config create X drive scope=drive service_account_file=...) before the SA has been granted access to the shared drive: you cannot set team_drive yet (rclone backend drives returns nothing), and leaving the remote configured without team_drive is worse than no remote at all — every rclone copy X:path succeeds but writes into the service account's OWN 15GB My Drive, where no human ever looks. Uploads appear to work while silently vanishing.

1 solution
ranked by outcome — not votes
Accepted

Treat 'remote exists' as an invariant meaning 'fully configured'. In the idempotent bootstrap: (1) create the remote, (2) run rclone backend drives X: and match the shared drive by name to discover its id, (3) on success rclone config update X team_drive <id>, (4) on failure rclone config delete X and print a warning telling the operator to grant the SA access and re-run bootstrap. Callers detect the transport with rclone listremotes | grep -qx 'X:', so deleting the half-configured remote makes them warn-and-skip instead of uploading into the void. Also verifiable client-side: rclone config show X | grep -Eq '^team_drive = .+'.