Skip to content
Storage Providers

Google Drive

Drive v3 transfers with Desktop PKCE loopback, 5-minute Cloud Console OAuth setup, Service Accounts, changes.list caching, and 750 GiB/day failover.

The gdrive backend (backend-gdrive) speaks Google Drive REST API v3 directly without external SDK bloat. It pairs Desktop PKCE loopback OAuth 2.0 (never the deprecated OOB flow) or RS256 Service Account JWTs with SQLite-backed incremental changes.list directory caching, CUBIC adaptive rate limiting, and bit-exact 308 resumable uploads.

Authorization Recipes#

# Opens browser on http://127.0.0.1:<ephemeral-port>/callback
rship auth gdrive gdrive \
  --client-id "<YOUR_CLIENT_ID>.apps.googleusercontent.com" \
  --client-secret "<YOUR_CLIENT_SECRET>" \
  --scope drive

# Move tokens into macOS/Windows/Linux OS Keyring
rship auth keyring-migrate
rship about gdrive:

OAuth 2.0 Setup#

You can also print this setup guide in your terminal anytime with rship auth gdrive --guide.

Choosing Your Authorization Path#

PathBest ForGoogle Review / CASA Audit?Setup Time
Path A: Bring Your Own Client ID (Recommended)Personal use, teams, self-hosted servers, power usersNone (Testing or Workspace Internal, up to 100 test users)~5 minutes
Path B: Public Verified OAuth AppDistributing a shared default Client ID to third-party usersYes for drive / drive.readonly (Restricted Scopes + annual CASA Tier 2). drive.file is Non-Sensitive (no CASA audit).2–6 weeks
Path C: Service Account (RS256 JWT)Automated CI/servers accessing Shared Drives or Workspace Domain-Wide DelegationNone~5 minutes

Path A: Create Your Own Desktop Client ID (5 Minutes)#

  1. Create Project & Enable API: Open Google Cloud Console, create/select a project (e.g. rship-personal-drive), go to APIs & Services → Library, search Google Drive API, and click Enable.
  2. Configure Auth Platform: Open Google Auth Platform → Overview → Get Started (or OAuth consent screen), set App name to rship, add your support email, and choose Internal (Google Workspace, never expires) or External (personal @gmail.com).
  3. Add Scopes & Test Users: Open Data Access → Add or Remove Scopes and pick the narrowest scope you need:
    • https://www.googleapis.com/auth/drive (--scope drive) — Full Drive access for syncing existing folders.
    • https://www.googleapis.com/auth/drive.file (--scope drive.file) — App-created files only (Non-Sensitive, zero CASA audit).
    • https://www.googleapis.com/auth/drive.readonly (--scope drive.readonly) — Read-only backup/mirror. Add every Google email you will authorize under Audience → Test users.
  4. Create Desktop App Credentials: Under Google Auth Platform → Clients → Create Client, pick Desktop app (required so Google permits http://127.0.0.1:<port>/callback loopback redirects) and copy the generated Client ID and Client Secret.
  5. Authorize & Verify: Run rship auth gdrive gdrive --client-id ... --client-secret ..., then verify with rship config test gdrive and rship about gdrive:. Running on a headless server? See Headless VPS, Docker & Keyring.

Path B: Public Verified OAuth App Checklist#

If you host a shared public Client ID for third-party users:

  1. Verified Domain & Public Homepage: Verify your domain in Google Search Console and host this standalone rship site (website/).
  2. Public Privacy Policy URL: Link directly to the Privacy Policy hosted on the same verified domain.
  3. App Logo (120×120 PNG): Published at /logo-120.png (from assets/logo-120.png).
  4. Scope Choice: Prefer drive.file (Non-Sensitive, fast verification, zero CASA fee) for shared public clients, while letting power users plug in their own Client ID via Path A for full drive access.
  5. Unlisted YouTube Demo Video: 60–90 s screencast showing rship auth gdrive ..., the visible client_id & scopes in the consent screen, clicking Allow, and running rship about, rship copy, and rship ls.

Path C: Service Account Notes#

Flags Reference (rship auth gdrive)#

FlagDefaultDescription
<REMOTE>—Logical remote name (e.g. gdrive, work-drive)
--client-idNoneGoogle Cloud OAuth 2.0 Desktop app client_id
--client-secretNoneOAuth 2.0 client_secret (required by Google Desktop OAuth token exchange)
--scopedriveAlias (drive, drive.file, drive.readonly) or full scope URL
--root-folder-idrootPin operations to a specific folder ID inside My Drive
--shared-drive-idNoneShared Drive (team_drive) ID; enables corpora=drive & supportsAllDrives=true
--service-account-fileNoneNon-interactive RS256 JWT key file for CI / servers
--impersonateNoneDomain-Wide Delegation subject email (sub)
--guidefalsePrint complete Cloud Console setup instructions and exit

Metadata Cache Modes & Tuning#

Because Google Drive is an ID-graph filesystem that permits duplicate sibling names, rship combines an in-process L0 IndexedDirLru (16,384 entries, cascading subtree invalidation) with an optional persistent L1 SQLite inventory (<state_dir>/inventory/*.db, schema v3 delta_nodes + scope_meta) kept current via changes.list and leased Shadow Generation MVCC.

metadata_cache Modes#

Configure metadata_cache in [remotes.<name>], via --metadata-cache <auto|sparse|full|off>, or via RSHIP_METADATA_CACHE:

ModeWhen the L1 delta_nodes mirror is builtBest For
auto (default)Built only on full-tree reconciliation commands (sync, bisync, check, dedupe) targeting a shallow prefix (depth <= 1) when not in overflow cooldown. Cold ls, ls -R | head, tree, copy, move, and deep-prefix sync (depth > 1) stream live with zero changes.list bootstrap calls. Once a mirror exists, warm listings reuse it via O(Delta) catch-up.General use, mixed ls / copy / sync workflows
sparseNever builds or queries persistent L1 delta_nodes; uses in-process L0 LRU + live streaming only. Cross-process mkdir exclusion (FileScopeLocker) still runs in persistent mode without opening SQLite. Global --no-changes-feed always forces sparse.Huge Shared Drives (> 500k nodes) or one-off transfers
fullAlways bootstraps/maintains L1 delta_nodes on listings (ignores prefix depth and the max_inventory_nodes overflow circuit breaker).Frequent repeat full-tree sync / bisync jobs
offDisables both L0 in-memory cache and L1 persistent inventory (pure stateless remote lookups; cross-process mkdir locking still active in persistent mode).Debugging or strict uncached reads
  • Legacy use_changes_feed mapping: use_changes_feed = true now maps to metadata_cache = "auto", and use_changes_feed = false maps to metadata_cache = "sparse". Setting metadata_cache explicitly overrides use_changes_feed; passing global --no-changes-feed always forces sparse.
  • Non-blocking bootstrap leases: Full bootstraps acquire a SQLite lease (120s TTL, 30s heartbeat) rather than a long-held file lock. If another rship process is already bootstrapping the same scope, peers never wait — they stream live immediately.
  • L1 TTL for point operations (l1_validation_ttl): Point operations (stat, mkdir, delete, single-file reads/uploads) trust an existing L1 mirror with zero locks and zero RPCs while now - validated_at <= l1_validation_ttl (default "60s"; set "0s" to disable L1 trust for point ops). When stale, point ops perform at most one non-blocking try-lock and up to 10 incremental changes.list pages (never rebuilding), falling back immediately to live lookup + L0 LRU on contention or large backlogs.

Remote Tuning & Multi-Process Coordination Keys#

toml
[remotes.gdrive]
type = "gdrive"
client_id = "<CLIENT_ID>.apps.googleusercontent.com"
client_secret = "keyring://rship/gdrive.gdrive.client_secret"
metadata_cache = "auto"           # auto | sparse | full | off
max_inventory_nodes = 500000      # auto-mode bootstrap circuit breaker (> 0)
overflow_cooldown = "7d"          # skip repeat auto bootstraps after overflow
sync_changes_mem_cap = 20000      # max in-RAM incremental changes before streaming rebuild (> 0)
l1_validation_ttl = "60s"         # point-op L1 cursor freshness TTL ("0s" disables)
quota_group = "corp-drive-acct"   # share 429 cooldowns & process slots across aliases
max_concurrent_processes = 2      # opt-in cross-process concurrency cap (>= 1; unset = unlimited)
stop_on_upload_limit = true
KeyDefaultDescription
metadata_cache"auto"Cache mode (auto, sparse, full, off). Propagates through crypt wrappers.
max_inventory_nodes500000Node cap for cold auto bootstrap; exceeding it aborts staging, records overflowed_at, and falls back to streaming.
overflow_cooldown"7d"Duration (>= 1s or "0s") to skip repeat auto bootstraps after hitting max_inventory_nodes.
sync_changes_mem_cap20000Max in-RAM changes / moved-in nodes during incremental catch-up before switching to a bounded streaming rebuild (keeps release Peak RSS <= 64 MiB).
l1_validation_ttl"60s"How long scope_meta.validated_at is trusted by point operations without re-checking changes.list.
quota_groupremote nameLogical account group shared across remote aliases for <state_dir>/cooldowns/*.json and process slots (supported on all 7 HTTP backends).
max_concurrent_processesunsetOpt-in limit on concurrent rship processes per quota_group using <state_dir>/locks/slots/. Every remote in a quota_group must use the same value. Zero filesystem activity when unset.

Protocol Internals, Lock-Wait Notices, Quota Failover & Dedupe#

  • Chunk geometry & 308 resume: Files <= 5 MiB use single-shot uploadType=multipart; larger files stream in 256 KiB-aligned resumable sessions (256 MiB default chunk size) with Content-Range resume persisted in SQLite WAL (journal.db).
  • Lock-wait notices & timeouts: Concurrent mkdir slow-path locks (FileScopeLocker) and OAuth2 <token_file>.lock refreshes poll with bounded jitter (5..=50ms), cancel immediately on SIGINT/SIGTERM, and time out after 300s (LockBusy, exit code 9). Process slots (max_concurrent_processes) wait cancellably without a timeout; commands that use several remotes reserve all their slots up front in sorted quota_group order, so they cannot deadlock each other. Any wait exceeding 1.5s emits a single advisory notice on stderr (printed above the live --tui / --progress display, or emitted as {"event":"notice","kind":"lock_wait",...} JSONL under --json-progress).
  • Write-QPS pacing, shared 429 cooldowns & 750 GiB/day limit: Writes are smoothed by an 8.0 creates/s default token bucket with CUBIC backoff on 403/429 and cross-process cooldown sharing via <state_dir>/cooldowns/ (capped at 30s, 1s floor). Pass global --drive-stop-on-upload-limit (RSHIP_DRIVE_STOP_ON_UPLOAD_LIMIT=1) to turn Google's daily 403 userRateLimitExceeded (750 GiB/day) quota cap into an immediate ErrorKind::QuotaExceeded, enabling automatic account rotation in the Rust SDK FailoverPool.
  • Duplicate filenames (rship dedupe): Because Drive permits sibling files with the same name, use rship dedupe gdrive:photos --mode newest (newest, oldest, largest, rename, or skip) to clean up duplicates safely by node ID.
  • Zero-reupload dedupe & server-side copy: Same-remote copies use files.copy, and rship cat supports HTTP Range downloads.