LabKey uses Google Apps for email, calendar and document sharing. With the release of Google Drive, I got a request to sync some files from an internal file share to the Google Doc/Drive.
The file server is on a linux server(Ubuntu 10.04 LTS), running SAMBA. There is currently not a linux client for Google Drive. But there is an open source client, Grive that I used for testing.
Given that Ubuntu 10.04 is getting a little long in the tooth, it took a bit of effort to get Grive compiled on the server.
Install the required software
There is not whole lot of documentation, but the Grive webpage gives an overview of the required libraries. I started from there and installed
apt-get install build-essential cmake make openssl
apt-get install libstdc++6 libstdc++6-4.4-dev
apt-get install libjson0 libjson0-dev expat libexpat1-dev
apt-get install libssl-dev libssl0.9.8
apt-get install libcurl4-openssl-dev
apt-get install binutils-dev
Install BOOST
The BOOST libraries are required, however, the compile failed when using v1.4.0, which is installed via APT. After some digging, I found that compilation problems were fixed in later versions. I downloaded and installed BOOST 1.4.9.
Install the perquisite software
apt-get install bzip2 libbz2-dev zip unzip
apt-get install python-dev
Download the latest version of BOOST
cd /usr/local/src
wget http://softlayer.dl.sourceforge.net/project/boost/boost/1.49.0/boost_1_49_0.tar.gz
tar xzf boost_1_49_0.tar.gz
Build and install the BOOST libraries
./bootstrap.sh
./b2
./b2 install
This installs the libraries into /usr/local/lib
and the header files into /usr/local/include
Build the grive software
Download and expand the software distribution
cd /usr/local/src
wget https://github.com/match065/grive/tarball/master
mv master match065-grive-b6fb4a6.tar.gz
tar xzf match065-grive-b6fb4a6.tar.gz
Build and install the software
cmake CMakeLists.txt
make
make install
This installs the binary at /usr/local/bin/grive
and the libraries into /usr/local/lib
Using grive software
In order to use the grive software, you will need to set the LD_LIBRARY_PATH
to include /usr/local/lib
. ie something like
export LD_LIBRARY_PATH=/usr/local/lib
Initialize
- Create a directory to hold the files from your Google Drive
- Follow the instructions in the Usage section at the Grive webpage to grant Grive access to your Google Drive.
NOTE: The authorization credentials for accessing your Google Drive account are stored in a file named .grive
. I strongly recommend
- securing this file so it can only be read by the owner of the directory
- blocking access to this file via SAMBA, if this is going to be a shared drive. (See hide files option)
Syncing your files and directories
To sync your files form Google Drive down to the local directory, all you need to do it run
/usr/local/bin/grive
Grive will sync in both direction and seems to work great. This is not a daemon, you will need to manually perform the sync after any files have been changed or your could use a CRON job to periodically perform the sync.