A CLI tool for bidirectional file synchronization between a local folder and Google Drive.
- Bidirectional sync — detects changes on both sides using a three-way diff algorithm
- Watch mode — monitors local filesystem changes and polls Drive automatically
- Conflict detection — interactive resolution or force local-wins with
--force - Google Docs support — exports Docs/Sheets/Slides to .docx/.xlsx/.pptx locally
- Dry-run mode — preview changes before executing
- SQLite state tracking — reliable change detection across sync runs
- Graceful shutdown — Ctrl+C finishes the current operation before exiting
go install github.com/SaqrWare/gdrive-sync@latestOr build from source:
git clone https://github.com/SaqrWare/gdrive-sync.git
cd gdrive-sync
go build -o gdrive-sync .- Create a Google Cloud project at console.cloud.google.com
- Enable the Google Drive API
- Create an OAuth 2.0 Client ID (application type: Desktop app)
- Download the credentials JSON file
gdrive-sync init --credentials /path/to/credentials.jsonThis will:
- Open your browser for Google OAuth2 authentication
- Prompt for the local folder path and Drive folder name/ID
- Save configuration to
~/.config/gdrive-sync/config.toml
Run a one-time sync:
gdrive-sync syncPreview changes without executing:
gdrive-sync sync --dry-runSync in one direction only:
gdrive-sync sync --direction up # local → Drive
gdrive-sync sync --direction down # Drive → localResolve all conflicts with local version:
gdrive-sync sync --forceContinuously monitor and sync:
gdrive-sync watchCustomize polling and debounce intervals:
gdrive-sync watch --poll 1m --debounce 5sShow pending changes:
gdrive-sync status
gdrive-sync status --jsonRemove cached OAuth token:
gdrive-sync logout
gdrive-sync logout --revoke # also revoke with GoogleConfig file: ~/.config/gdrive-sync/config.toml
local_path = "/home/user/my-drive-folder"
remote_folder_id = "1ABC..."
remote_folder_name = "My Folder"
delete_mode = "trash" # "trash" or "permanent"
google_docs_mode = "export_readonly" # "export_readonly" or "skip"
exclude = ["*.tmp", ".git"]
[export]
"application/vnd.google-apps.document" = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
"application/vnd.google-apps.spreadsheet" = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
"application/vnd.google-apps.presentation" = "application/vnd.openxmlformats-officedocument.presentationml.presentation"The sync engine uses a three-way diff comparing:
- Local filesystem — current state of files on disk
- Google Drive — current state of files in the remote folder
- Sync state database — snapshot from the last successful sync (stored in SQLite)
This allows accurate detection of which side changed, including deletions. Conflicts are raised when both sides changed since the last sync.
MIT