A cross platform CLI tool for synchronizing folders between google drive and local file-system (both ways).
NOTE: This is the development branch.
- Create a poject in google cloud console.
- Under
APIs and Services
, click onOAuth Consent Screen
. - Enter application name, for example
yourname-gsync
. Fill in other details. - Once OAuth Consent Screen is configured, click on
Clients
, then click onCreate Client
. - Select Application Type as
Web Application
. UnderAuthorized redirect URIs
fill some localhost addresses likehttp://localhost:8121
etc. - Click on
Create
and download thejson
file. Rename this file asclient.json
. - On linux, put this file at
~/.config/gsync/client.json
. On windows, atC:\Users\<Username>\AppData\Local\gsync\client.json
.
gsync
uses uv
to manage the project dependencies. You can find the steps to install uv
here.
git clone https://github.com/px86/gsync
cd gsync
uv sync
uv run gsync.py --help
gsync
syncs file based on source and destination folders. For example, the below command will initialize a local copy of your google drive, into the local-drive/
folder. Here the source is gd:/
and local-drive/
is the destination. -r means recursively.
gsync gd:/ local-drive/ -r
Note that all google drive paths start with gd:
prefix. gd:/
refers to the My Drive
folder in your google drive, gd:/Documents/
will refer to My Drive/Documents/
and so on.
You can switch the source and destination to sync in the reverse direction.
It is also possible to sync a given subdirectory only. For example, the below command will make sure that all files in the local-drive/Documents/Work/
folder are present and up-to-date in the drive in My Drive/Documents/
folder.
gsync local-drive/Documents/Work/ gd:/Documents/
usage: gsync.py [-h] [-r] [-c] [--dry-run] [--max-size SIZE] sourcedir destinationdir
positional arguments:
sourcedir
destinationdir
options:
-h, --help show this help message and exit
-r, --recursive sync source recursively
-c, --checksum use checksum instead of modified time and size to compare files
--dry-run only print the updates, do not do anything
--max-size SIZE skip files which are greater than SIZE bytes