Git Product home page Git Product logo

gsync's Introduction

gsync

A python tool for syncing files between google drive and local file-system (both ways).

NOTE: This is the development branch. No commits have been made to the main/master branch yet.

Installation

Step 0: getting credentials

You will need three credentials: client_id, client_secret, and refresh_token, to use this tool. To get these, you need to:

  1. Create a poject in google cloud console.
  2. Confiugure the consent screen.
  3. Obtain the client_id and client_secret.
  4. Authorize to google drive via OAuth 2.0 Playground and get a refresh_token.

Now, export these secrets as CLIENT_ID, CLIENT_SECRET, and REFRESH_TOKEN environment variables.

Step 1: installing gsync

git clone https://github.com/px86/gsync
cd gsync
pipenv install
pipenv run python gsync.py --help

Usage

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/

the –help option

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

gsync's People

Contributors

px86 avatar

Watchers

 avatar  avatar

gsync's Issues

TODO: implement an authentication flow

When a refresh token is not available or has expired, start a local http server. The user will be presented with a login screen, and once the user has logged in, the http server will receive an auth code. The auth code will be exchanged for a refresh token and the server will be shutdown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.