URL: https://mkdocs.justinsforge.com/memory/general/reference_gdrive_folder_upload/
Bulk local-tree to Google Drive uploader¶
forge/scripts/forge_gdrive_folder_upload.py uploads a local directory tree to
Google Drive preserving folder structure. Built 2026-07-01 for the Sip-N-Serve
Takeout upload; generalized because "put this whole folder in Drive" recurs.
Why it exists (do not use rclone for this)¶
Console's only rclone remote (gdrive:) has an unverifiable account:
rclone config userinfo gdrive: is blocked and its config shows a 6 TiB quota
that does not obviously match [email protected]. Uploading 500 MB+ to a
mystery account is the exact mistake to avoid. This script instead uses the
canonical forge_google_user.user_token("personal"|"business") path, fetches
about.user.emailAddress, and (with --expect-account) aborts loudly on
mismatch. Talks raw Drive v3 REST via requests (matches forge_google_user's
stdlib style; the Google client libs are NOT installed in system python, only
in ~/.venvs/browser and ~/.venvs/kuma).
Usage¶
python3 forge_gdrive_folder_upload.py \
--local <dir> --name '<drive folder name>' \
[--parent <parentId|root>] [--account personal|business] \
[--expect-account [email protected]] \
[--share [email protected]] [--share-role writer|reader]
- Creates
--nameunder--parent(default My Drive root), recreates every subfolder, uploads every file with a resumable PUT that streams from disk (handled a 439 MB mbox without touching memory or agent context). --shareadds a permission (default writer) with an email notification.- Prints
account:, the folder id, per-fileup:lines, a finaluploaded/skipped/bytessummary, and the folderwebViewLink.
Idempotency¶
Before uploading into a folder it lists existing children and skips any file whose name + byte size already match, so a re-run resumes instead of duplicating. It does NOT delete or update remote files that differ; it only adds missing ones.
Proven run¶
2026-07-01: uploaded /mnt/storage/forge-archive/sipnserve-takeout-2026-06-09/extracted/Takeout
(652 files, 596 MB) to My Drive folder Sip-N-Serve Takeout 2026-06-09
(id 1ldp84IH1_ocb-WQqEG6IF3UfPOpEr5rh), shared writer to
[email protected]. Exit 0, 0 skipped.
[Claude Code]