Материал из YourcmcWiki
Перейти к: навигация, поиск

Welcome to the Grive2 project homepage!

The purpose of this project is to provide an independent open source implementation of Google Drive client for GNU/Linux. It uses Google Drive REST API to talk to Google Drive service. The code is written in standard C++.

Grive2 is the fork of the original abandoned «Grive» ( with added support for the new Drive REST API (original version was using the «Document List API» which is now shut down) and some new features, for example, partial sync.

The source code of Grive2 is released under GPLv2.


  • Grive2 can do two-side synchronization between the Google Drive and local directory: it can download and upload changed files, create new directories, and move deleted files to trash.
  • Dry run: you can see what actions Grive2 wants to perform with your files without really performing them (--dry-run option).
  • You can select a single subdirectory to sync with '-s subdir' option or you can exclude some files from sync with '--ignore <regexp>' option. <regexp> has perl regexp syntax and is matched against local relative path inside synced root directory. Note that --ignore / -s value is remembered by Grive so call grive --ignore '' if you want to sync the whole root after syncing a single subdirectory.


The following features are not planned to be supported in the near future. The main reason is that Google Drive supports much more features than a local file system. It is not easy/feasible/practical to mimic everything in Google Drive to a directory in a computer.

See also the FAQ for the rationale behind them.

Folders/files with multiple parents
The structure of a Google Drive is not exactly organized in a hierarchy. It is more similar to an interconnected net attached to a single root point (quoted from the API reference). Obviously the files and directories in the file system have only one parent. Therefore, this feature cannot be implemented very easily.
Folders/files with '/' in name
'/' is the directory separator and cannot be used in file names.
Multiple folders/files with the same name
Current Grive2 behaviour is undefined with such files.
Downloading Google Documents
This feature is not currently implemented. If the demand for it is big enough, it may be implemented later. Patches are welcomed.


The following are instructions for compiling from the very latest «master branch» source and running `grive` in Debian/Ubuntu/Linux Mint.

Get dependencies

You need to get the dependency libraries along with their development (-dev or -devel) packages:

  • yajl 2.x
  • libcurl
  • STL (libstdc++)
  • libgcrypt
  • Boost (filesystem, program_options, regex, unit_test_framework and system)
  • expat

There are also some optional dependencies:

  • CppUnit (for unit tests)
  • libbfd (for backtrace)
  • binutils (for libiberty, required for compilation in OpenSUSE, Ubuntu, Arch and etc)

And tools:

  • Git
  • CMake
  • C++ compiler (g++ or clang)

On a Debian/Ubuntu/Linux Mint machine just install the following packages:

sudo apt-get install git cmake build-essential libgcrypt11-dev libyajl-dev libboost-all-dev libcurl4-openssl-dev libexpat1-dev libcppunit-dev binutils-dev


pkg install git cmake boost-libs yajl libgcrypt pkgconf cppunit libbfd

Build debian package

Source repository already contains debian packaging scripts.

So, to build the debian package, install dpkg-dev and run dpkg-buildpackage -j4 in the source directory. *.deb package will be generated in the parent directory.

Download sources


Now that you are in the source code's “grive2” subdirectory (after 'cd /path/to/yourGriveSourceCodeDir/grive2'), at the prompt type:

mkdir build
cd build
cmake ..
  • note the double period (..) as the argument to cmake, to denote the parent directory.
  • You should get a success message like: ”– Build files have been written to: /your/dir”
  • Don't run it with sudo - root access is not needed for building.

Make and install

At the prompt type:

make -j4

You'll get lots of messages & hopefully a success message: ”[100%] Built target grive_executable”. The executable file itself (called “grive”) will be placed in the “grive” subdirectory.

Then install it to the system binary directory (/usr/local/bin by default) by running:

sudo make install


For subsequent updates, you'll run `git pull` to get the latest source and then just rebuild and re-install it:

cd /path/to/yourGriveSourceCodeDir/grive2
git pull
cd build
cmake ..
make -j4
sudo make install

Note.svg Check out this git book for more info about git, if you don't know what it is.

Note that there can be a delay in updating the archive (ZIP button on bottom right) at, and it may not have the very latest. Pulling from git ensures the very latest.



Since grive is still «beta» or «alpha» you should better keep a backup copy of your google directory.

First run

Change to your google drive sync directory, and run grive -a:

cd /home/you/yourGoogleDrive/
grive -a

Note.svg The «-a» option is only needed the very first time you run grive.

Visit the URL that comes up, then post the auth code given (you must have been logged into Google). You should get some messages including «Synchronizing files» … now you are running.


To sync, you must run the program manually (there is no «real-time watching» yet). At the prompt, type:

cd /home/you/yourGoogleDrive/

You can set up a cron job, if you want this done on a regular basis.

Command line options

Short option Long option Description
-h --help Produce help message
-v --version Display Grive version
-a --auth Request authorization token
-p arg --path arg Root directory to sync
-s arg --dir arg Single subdirectory to sync (remembered for next runs)
-V --verbose Verbose mode. Enable more messages than normal.
--log-http arg Log all HTTP responses in this file for debugging.
--new-rev Create new revisions in server for updated files.
-d --debug Enable debug level messages. Implies -v.
-l arg --log arg Set log output filename.
-f --force Force grive to always download a file from Google Drive instead of uploading it.
--dry-run Only detect which files need to be uploaded/downloaded, without actually performing them.
--ignore arg Perl RegExp to ignore files (matched against relative paths, remembered for next runs).

Reporting bugs

If you get some kind of «crash» (bunch of error messages on the screen), please run grive with the following options:

grive -l log.txt --log-http http

`log.txt` and `httpXXXX-XX-XX.XXXXXX.txt` files will be created. Please note these files may contain authentication tokens and file contents, so edit them before submitting.

Then create an issue on github: and attach these files.


  • (Maybe) Implement «daemon mode» for continuous sync without running grive many times

Version History

Grive2 v0.5 (unreleased)

  • Much faster and more correct synchronisation using local modification time and checksum cache (similar to git index)
  • Automatic move/rename detection, -m option removed
  • force option works again
  • Instead of crashing on sync exceptions Grive will give a warning and attempt to sync failed files again during the next run.
  • Revision support works again. Grive 0.4.x always created new revisions for all files during sync, regardless of the absence of the --new-rev option.

Grive2 v0.4.2

  • Option to exclude files by perl regexp
  • Reimplemented HTTP response logging for debug purposes
  • Use multipart uploads (update metadata and contents at the same time) for improved perfomance & stability
  • Bug fixes
  • Simple option to move/rename files and directories, via `grive -m oldpath newpath` (by Dylan Wulf,

Known issues:

  • force option does not work as documented #51

Grive2 v0.4.1

  • Bug fixes

Grive2 v0.4.0

First fork release, by Vitaliy Filippov / vitalif at mail*ru

  • Support for the new Google Drive REST API (old «Document List» API is shut down by Google 20 April 2015)
  • REAL support for partial sync: syncs only one subdirectory with `grive -s subdir`
  • Major refactoring — a lot of dead code removed, JSON-C is not used anymore, API-specific code is split from non-API-specific
  • Some stability fixes from Visa Putkinen
  • Slightly reduce number of syscalls when reading local files.

Grive v0.3.0

Bug fix & minor feature release. Fixed bugs:

  • #93: missing reference count increment in one of the Json constructors
  • #82: retry for HTTP error 500 & 503
  • #77: Fixed a bug where grive crashed on the first run.

New features:

  • #87: support for revisions
  • #86: partial sync (contributed by justin at that’s not partial sync, that’s only support for specifying local path on command line


Please send pull requests here:

Full list of contributors


  • Vitaliy Filippov (vitalif *at* 08.09.2013 — NOW
  • Nestal Wan (me *at* 16.05.2012 — 03.05.2013
  • Matchman Green (match065 *at* 26.04.2012 — 20.06.2012


  • Dylan Wulf (wulfd1 *at*
  • Visa Putkinen (visa.putkinen *at*
  • justin (justin *at*
  • Stephen Cox (stephencoxmail *at*
  • Jan Winkler (winkler *at*
  • Caleb Maclennan (caleb *at*
  • Ben L (nightgunner5 *at*
  • Georges Dubus (georges.dubus *at*
  • georg wiltschek (georg.wiltschek *at*
  • Erik Hardesty (dalingrin *at*
  • José Luis Segura Lucas (josel.segura *at*
  • LemonBoy (thatlemon *at*
  • manuken (jesus.bustos *at*
  • Eshwar Andhavarapu (gontadu *at*
  • Andrea Scarpino (andrea *at*
  • Sunnywout (woutervdb97 *at*
  • Massimo Gengarelli (gengarel *at*