Skip to content
dogbutcatPublic

About

fork from https://github.com/donwa/gclone

Topics

Resources

Stars

198 stars

Watchers

6 watching

Forks

Repository files navigation

gclone

A modified version of the rclone

Implement donwa/gclone to sync with rclone version

Provide dynamic replacement sa file support for google drive operation

BUILD

Prepare

#Windows cgo
WinFsp, gcc (e.g. from Mingw-builds)

#macOS
FUSE for macOS, command line tools

#Linux
libfuse-dev, gcc

Step

  • (optional) install cgofuse
  • build
    go build -v -tags 'cmount' gclone.go
    

Check

./gclone version

if need mount function, cgofuse is required,

Local VFS compatibility copy

The VFS and its command adapters are synced with rclone v1.75.2 in this repository to isolate unlinked and rename-overwritten files from old handles, metadata updates and delayed writeback. Local consistency guards also keep delayed directory snapshots from discarding newly uploaded cache data. Builds use the normal go build command and the official rclone module dependency.

flowchart TD
    Entry["gclone entry"] --> Registry["Command and backend registration"]
    Registry --> Adapters["Local mount / serve / archive / updater adapters"]
    Adapters --> VFS["Local vfs: v1.75.2 snapshot + lifecycle fix"]
    VFS --> FS["Official rclone fs interfaces"]
    FS --> Drive["gclone Drive / SA customization"]
    FS --> Backends["Other official backends"]
    Fixed["Upstream release passes the same regressions"] -.-> Drop["Restore imports and remove copied paths"]
Loading

See VFS maintenance and removal notes and the file provenance manifest. Mount/serve adapters must use the same VFS to avoid duplicate RC and option registration. The copied upstream selfupdate command remains separate from gclone's gselfupdate.

Instructions

1.service_account_file_path Configuration

add service_account_file_path Configuration.For dynamic replacement service_account_file(sa file). Replace configuration when rateLimitExceeded error occurs rclone.conf example:

[gc]
type = drive  
scope = drive  
service_account_file = /root/accounts/1.json  
service_account_file_path = /root/accounts/  
root_folder_id = root  

/root/accounts/ Folder contains multiple access and edit permissions service account file(.json)*.

The directory is searched recursively, so project1/file.json and project2/file.json can coexist. Normalized absolute paths identify credential files; basenames are never flattened or used as unique keys. Nested directory symlinks are not traversed. A symlink used as the root, or a file symlink pointing to a regular JSON file, is supported and retains the configured path identity.

Pool discovery validates JSON type, account email presence and RSA private-key structure locally. Unreadable, missing or malformed candidates are skipped with path-only diagnostics; no token or Drive request is made during validation. An empty/unusable pool or directory traversal failure is reported, and a failed reload leaves the previous pool intact. A credential that becomes invalid after discovery is excluded when rotation next tries it, allowing other candidates to be tried. A repaired file becomes eligible on a later successful directory rescan or restart; this is not a live file watcher. Server-side revocation, permissions and quota errors remain governed by the existing request/retry behavior.

SA rotation strategy

Set service_account_file_strategy in rclone.conf, or use --drive-service-account-file-strategy on the command line:

Value Proactive rolling (rolling_sa = true) Quota-triggered switching
default (default) Existing sequential file rotation Existing random account selection
cross-folder Prefer the next eligible directory group Prefer the next eligible directory group

cross-folder requires service_account_file_path. It applies to both switching paths, but does not itself enable proactive rotation; set rolling_sa = true separately. Initial selection with random_pick_sa is unchanged: it chooses randomly from the valid files in the directory, rather than choosing a group. service_account_file is optional when random_pick_sa = true. Quota-triggered switching still follows the existing retry rules: it handles rateLimitExceeded / userRateLimitExceeded with a configured directory when stop_on_upload_limit is false. The strategy does not override that stop option. The default strategy does not require a directory for normal OAuth use.

For example, project1/a.json and project1/nested/b.json belong to the same group, while project2/a.json belongs to another. Groups and files are sorted by full path. Each group has its own circular position: groups with fewer files wrap around rather than dropping out, so unequal group sizes still alternate. JSON files directly in the root form a separate group. An explicitly selected file outside the root is grouped by its parent directory.

Unavailable accounts are skipped individually. If no other group has an eligible account, selection falls back to another account in the current group. Successful switches advance the group's position; failed or cancelled construction does not. If the active client's credential file is removed, rotation still uses that client's original group when choosing a replacement. A failed or cancelled replacement leaves the active client unchanged.

For example, with /path/to/accounts containing:

accounts/
  project1/
    a.json
    b.json
    nested/c.json
  project2/
    a.json

Starting from project1/a.json, successful switches follow project2/a.json → project1/b.json → project2/a.json → project1/nested/c.json → project2/a.json → project1/a.json. This example assumes every file remains eligible and no other switch intervenes. The single-file group keeps its turn instead of being exhausted after one use.

rclone.conf example (replace the paths and folder ID with your own values):

[gc]
type = drive
scope = drive
service_account_file = /path/to/accounts/project1/a.json
service_account_file_path = /path/to/accounts
service_account_file_strategy = cross-folder
rolling_sa = true
rolling_count = 4
root_folder_id = FOLDER_ID

With a mount-enabled build (see BUILD), mount using that configuration:

gclone mount gc: /path/to/mountpoint \
  --config /path/to/rclone.conf \
  --vfs-cache-mode=full

Or supply the strategy and initial random selection on the command line for an existing gc Drive remote:

gclone mount gc: /path/to/mountpoint \
  --config /path/to/rclone.conf \
  --drive-service-account-file-path=/path/to/accounts \
  --drive-service-account-file-strategy=cross-folder \
  --drive-random-pick-sa \
  --drive-rolling-sa --drive-rolling-count=4 \
  --vfs-cache-mode=full

All selected SAs need permission to access the target. Directory groups are user-defined; folder names do not establish Google Cloud project identities. rolling_count sets transfer concurrency, not a reservation of a unique SA for each concurrent transfer. Rotation does not guarantee avoidance of Google quotas or permission failures.

2.Support incoming id

If the original rclone is across team disks or shared folders, multiple configuration drive letters are required for operation. gclone supports incoming id operation

gclone copy gc:{folder_id1} gc:{folder_id2}  --drive-server-side-across-configs

folder_id1 can be:Common directory, shared directory, team disk.

gclone copy gc:{folder_id1} gc:{folder_id2}/media/  --drive-server-side-across-configs

gclone copy gc:{share_field_id} gc:{folder_id2}  --drive-server-side-across-configs

3.Support command line option --drive-service-account-file-path

gclone copy gc:{share_field_id} gc:{folder_id2} --drive-service-account-file-path=${SOMEWHERE_STORE_SAs}

4.Support command line option --drive-rolling-sa and --drive-rolling-count

gclone copy gc:{share_field_id} gc:{folder_id2} --drive-rolling-sa --drive-rolling-count=1

What is rolling sa?

  • This option main for backup large drive, intent for using all sa more balance, not to consume one sa in one time, as I found there's some wired scen when sa was consumed.

What is rolling count?

  • With rolling_sa enabled, this sets the parallel transfer count. It does not change recursive listing workers (--checkers) or reserve a distinct SA for each transfer. The default is 1; values above 4 are not recommended. Each request keeps its issuing SA for error attribution, and successful resumable upload sessions retain their initiating SA.

5.Support command line option --drive-random-pick-sa

gclone copy gc:{share_field_id} gc:{folder_id2} --drive-random-pick-sa --drive-rolling-sa --drive-rolling-count=1
  • Select an initial SA from the locally valid regular .json files recursively found in service_account_file_path. service_account_file is optional in this mode; an inherited initial file or inline service_account_credentials does not override the selected file. Good companion with rolling_sa.
  • The directory is required and must contain a usable credential file. Invalid candidates are skipped; directory traversal errors are reported directly. Normal authentication precedence is unchanged when random selection is disabled.

6.Support new command gselfupdate and gversion

From 1.64.0-mod1.6.0 gclone add new command to update itself, parallel working with rclone's selfupdate

gclone gselfupdate [--check] [--output [of]] [--version [v]] [--package [zip|deb|rpm]]

CAVEATS

Creating Service Accounts (SAs) allows you to bypass some of Google's quotas. Tools like autorclone and clonebot (gclone) automatically rotate SAs for continuous multi-terabyte file transfer.

Quotas SAs CAN bypass:

  • Google 'copy/upload' quota (750GB/account/day)
  • Google 'download' quota (10TB/account/day)

Quotas SAs CANNOT bypass:

  • Google Shared Drive quota (~20TB/drive/day)
  • Google file owner quota (~2TB/day)

About

fork from https://github.com/donwa/gclone

Topics

Resources

Stars

198 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages