How to mount your google drive on Raspbian RPI with GDriveFS


27 posts   Page 1 of 2   1, 2
by pageauc » Wed May 06, 2015 3:37 am
IMPORTANT
Please read farther down this post for a better solution than GDriveFS called gdrive
gdrive info here https://github.com/pageauc/pi-timolo/wiki/How-to-Setup-gdrive-sync
post permalink here https://www.raspberrypi.org/forums/viewtopic.php?p=801697#p801697
Claude ....


How to mount your web based google drive onto a Raspbian RPI using GDriveFS
NOTE I am now using gdrive instead of GDriveFS see my later posts for details or https://github.com/pageauc/pi-timolo Readme.md under gdrive sync heading.

Written by Claude Pageau email: pageauc@gmail.com based on info below
For more details see https://github.com/dsoprea/GDriveFS

I have been using grive for my python pi-timolo project https://github.com/pageauc and recently grive failed.
grive is pooched as of 20-Apr-2015 due to google updating the docs api.
For details see https://developers.google.com/google-apps/documents-list/

I notified mathiew on github https://github.com/linwiz/grive who manages the most up-to-date maintained copy of grive that I could find, to let him know about the problem. In the mean time I went looking for an easy to implement alternative solution that would allow my camera security images to be uploaded easily to my google drive. I have written a sync-leavelast.sh script to automate the GDriveFS sync process. This bypassed the most recent file since the camera may still be writing the file. This avoids a camera crash. If you are interested I have some basic instructions below.

Instructions
This is the simplest way I have found to connect your google drive to the RPI via a file system mount point
Login to your Raspbian distro raspberry pi using putty ssh or desktop terminal session
make sure your RPI is up to date. Note you may not need upgrade.
Code: Select all
cd ~
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip

Note the command below will take a while to install so be patient
Code: Select all
sudo pip install gdrivefs

Once install above is complete, we need to create authorization credentials with your google account on the web
This will allow you to mount your google drive onto your RPI file system. This will require cutting and pasting to/from
a browser session on your PC. You may also be able to do this from a RPI desktop browser as long as
you can login to your google account, eg gmail.
Code: Select all
gdfstool auth -u

The command above will return a long web url.
1 - In PC putty terminal use mouse to highlight the url text (do not hit enter)
2 - On the PC open chrome browser and make sure you are logged into your google account. Eg gmail
3 - On the PC in chrome browser url box at top of browser right click and paste url into the url box and go to url
4 - This should give you a google web page that asks you to accept the permissions.
5 - Accept the permissions to get a screen with a security token. Right click in the box and copy the security token
6 - On the raspberry pi putty or terminal session execute the following command to create a credential file
Code: Select all
gdfstool auth -a /home/pi/gdfs.creds "paste token here with quotes"

7 - paste (right click) the token inside the quotes in command above. This will create a /home/pi/gdfs.creds file
if that went OK it is now time to mount your google drive to your raspberry pi. perform the command below
Code: Select all
sudo mkdir /mnt/gdrivefs
sudo gdfs -o allow_other /home/pi/gdfs.creds /mnt/gdrivefs
ls /mnt/gdrivefs

the ls command above will list your google drive files. If not then check your steps above
if you wish to create a symlink in your /home/pi folder to make it easier to access the /mnt/gdrivefs folder
then create a soft link per below. You can change link name and/or location to suit your needs.
Code: Select all
ln -s /mnt/gdrivefs /home/pi/gdrivefs

list files in the /home/pi/gdrivefs symlink folder
Code: Select all
ls gdrivefs

To create a permanent mount that gets connected on boot. Make a backup of you fstab then
edit using nano or similar editor on the pi and add the new gdrivefs entry
Code: Select all
sudo cp /etc/fstab /etc/fstab.bak
sudo nano /etc/fstab

Make the symlink::
Code: Select all
sudo ln -s /usr/local/bin/gdfs /sbin/mount.gdfs

add the following text at the bottom of the /etc/fstab using the nano editor then ctrl-x and y to save
Code: Select all
/home/pi/gdfs.creds /mnt/gdrivefs gdfs allow_other 0 0

To manually mount or unmount use the following commands
Code: Select all
sudo mount /mnt/gdrivefs
sudo umount /mnt/gdrivefs

Important Message
I have not at this point figured out a way to auto mount the drive from the /etc/fstab. Still working on trying to get headless mounting of my gdrivefs. If I connect in a terminal session then exit the mount remains but the connection is broken. The only way to get it back is to unmount and mount again. Let me know if you have a solution. In the mean time it does give access to your google drive via a Raspberry Pi mount point. On the RPI you can mkdir, cp, rm, mv on the gdrivefs using normal unix commands. Please note that there will be a little lag (delay) since the mount is connected via the internet. For example if you delete a file it will take a while for it to actually disappear from a GDriveFS directory listing.

You can also do some basic file operations via the various google drive apps on various devices eg Win PC, IOS, Android, Etc. I use google drive on my IOS device to view security camera images.

Regards
Claude ...
Last edited by pageauc on Mon Sep 26, 2016 6:48 pm, edited 7 times in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by fatez » Mon May 25, 2015 7:59 am
Hi,

i have a problem to install, see the log pls :

Code: Select all
/usr/bin/pip run on Mon May 25 07:53:42 2015
Requirement already satisfied (use --upgrade to upgrade): gdrivefs in /usr/local/lib/python2.7/dist-packages

Requirement already satisfied (use --upgrade to upgrade): fusepy==2.0.2 in /usr/local/lib/python2.7/dist-packages (from gdrivefs)

Downloading/unpacking gevent==1.0 (from gdrivefs)

  Running setup.py egg_info for package gevent

    running egg_info
    writing requirements to pip-egg-info/gevent.egg-info/requires.txt
    writing pip-egg-info/gevent.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/gevent.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/gevent.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/gevent.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/gevent.egg-info/SOURCES.txt'
  Source in ./build/gevent has version 1.0, which satisfies requirement gevent==1.0 (from gdrivefs)
Downloading/unpacking gipc==0.4.0 (from gdrivefs)

  Running setup.py egg_info for package gipc

    running egg_info
    writing requirements to pip-egg-info/gipc.egg-info/requires.txt
    writing pip-egg-info/gipc.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/gipc.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/gipc.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/gipc.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/gipc.egg-info/SOURCES.txt'
  Source in ./build/gipc has version 0.4.0, which satisfies requirement gipc==0.4.0 (from gdrivefs)
Downloading/unpacking google-api-python-client==1.2 (from gdrivefs)

  Running setup.py egg_info for package google-api-python-client

    running egg_info
    writing requirements to pip-egg-info/google_api_python_client.egg-info/requires.txt
    writing pip-egg-info/google_api_python_client.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/google_api_python_client.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/google_api_python_client.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/google_api_python_client.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.json' under directory 'apiclient'

    writing manifest file 'pip-egg-info/google_api_python_client.egg-info/SOURCES.txt'
  Source in ./build/google-api-python-client has version 1.2, which satisfies requirement google-api-python-client==1.2 (from gdrivefs)
Downloading/unpacking greenlet==0.4.2 (from gdrivefs)

  Running setup.py egg_info for package greenlet

    running egg_info
    writing pip-egg-info/greenlet.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/greenlet.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/greenlet.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/greenlet.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/greenlet.egg-info/SOURCES.txt'
  Source in ./build/greenlet has version 0.4.2, which satisfies requirement greenlet==0.4.2 (from gdrivefs)
Downloading/unpacking httplib2==0.8 (from gdrivefs)

  Running setup.py egg_info for package httplib2

    running egg_info
    writing pip-egg-info/httplib2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/httplib2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/httplib2.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/httplib2.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/httplib2.egg-info/SOURCES.txt'
  Source in ./build/httplib2 has version 0.8, which satisfies requirement httplib2==0.8 (from gdrivefs)
Downloading/unpacking python-dateutil==2.2 (from gdrivefs)

  Running setup.py egg_info for package python-dateutil

    running egg_info
    writing requirements to pip-egg-info/python_dateutil.egg-info/requires.txt
    writing pip-egg-info/python_dateutil.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/python_dateutil.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/python_dateutil.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/python_dateutil.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/python_dateutil.egg-info/SOURCES.txt'
  Source in ./build/python-dateutil has version 2.2, which satisfies requirement python-dateutil==2.2 (from gdrivefs)
Downloading/unpacking six==1.7.3 (from gdrivefs)

  Running setup.py egg_info for package six

    running egg_info
    writing pip-egg-info/six.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/six.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/six.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found
   

    reading manifest file 'pip-egg-info/six.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'documentation/_build'

    writing manifest file 'pip-egg-info/six.egg-info/SOURCES.txt'
  Source in ./build/six has version 1.7.3, which satisfies requirement six==1.7.3 (from gdrivefs)
Installing collected packages: gevent, gipc, google-api-python-client, greenlet, httplib2, python-dateutil, six

  Running setup.py install for gevent

    Running command /usr/bin/python -c "import setuptools;__file__='/home/pi/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dKDRdT-record/install-record.txt
    running install
    running build
    running build_py
    running build_ext
    building 'gevent.core' extension

    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CHECK_ENABLE=0 -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -Ibuild/temp.linux-armv7l-2.7/libev -Ilibev -I/usr/include/python2.7 -c gevent/gevent.core.c -o build/temp.linux-armv7l-2.7/gevent/gevent.core.o

    gevent/gevent.core.c:17:20: fatal error: Python.h: No such file or directory

    compilation terminated.

    error: command 'gcc' failed with exit status 1

    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/pi/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dKDRdT-record/install-record.txt:

    running install

running build

running build_py

running build_ext

building 'gevent.core' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CHECK_ENABLE=0 -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -Ibuild/temp.linux-armv7l-2.7/libev -Ilibev -I/usr/include/python2.7 -c gevent/gevent.core.c -o build/temp.linux-armv7l-2.7/gevent/gevent.core.o

gevent/gevent.core.c:17:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------

Command /usr/bin/python -c "import setuptools;__file__='/home/pi/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dKDRdT-record/install-record.txt failed with error code 1 in /home/pi/build/gevent

Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 104, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 250, in run
    requirement_set.install(install_options, global_options)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1133, in install
    requirement.install(install_options, global_options)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 577, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 256, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/home/pi/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dKDRdT-record/install-record.txt failed with error code 1 in /home/pi/build/gevent
pi@raspberrypi ~ $
Posts: 2
Joined: Mon May 25, 2015 7:57 am
by fatez » Mon May 25, 2015 10:48 am
Looks like I haven't properly installed the header files and static libraries for python dev.

The solution :

Code: Select all
sudo apt-get install python-dev
Posts: 2
Joined: Mon May 25, 2015 7:57 am
by pageauc » Sun Jun 14, 2015 12:56 am
I have found a good replacement for grive that I have incorporated this into the latest release of pi-timolo at https://github.com/pageauc/pi-timolo See sync.sh file in sources for my implementation. This binary does not need any dependencies and is easy to setup security. I have instructions with the pi-timolo Readme.md FYI but you can go to the developer repo per links below.

This link is a self contained precompiled binary for RPI. It has been working for me without issues
https://github.com/odeke-em/drive/releases. Version 2.2 arm binary can be downloaded here https://github.com/odeke-em/drive/releases/tag/v0.2.2-arm-binary
For implementaion details see https://github.com/odeke-em/drive

In pi-timolo project I have named by binary gdrive and copied it to /usr/local/bin but you can name it drive or whatever you like.

Claude ...
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by NablaMetal » Wed Aug 12, 2015 3:17 pm
Has anyone tried this ?

Last time I tried to setup GDrive, it messed up my whole raspberry setup and I had to restore my sd backup... I am afraid to try this.

--
NablaMetal
Posts: 4
Joined: Wed Aug 12, 2015 3:12 pm
by pageauc » Wed Aug 12, 2015 9:36 pm
I have had problems with a previous program called gdriveFS. per post above, I have found a much better solution IMO that is documented in my github repo. This solution does not require any dependencies and works out of the box. Details are in my Readme.md under heading setup gdrive sync. Here is my github repo where you can download file. For convenience I have named the file gdrive.
https://github.com/pageauc/pi-timolo/tree/master/source

You can also download this file from the original developer github per the following
Code: Select all
cd /tmp
wget https://github.com/odeke-em/drive/releases/download/v0.2.2-arm-binary/drive-arm-binary
chmod +x drive-arm-binary
sudo cp drive-arm-binary /usr/local/bin/gdrive
cd ~
gdrive version


I have found the pre compiled gdrive works very well and gives good control using push or pull to sync specific folders. Therefore you can avoid a two way sync that can sometimes be problematic. Anyway give it a try and I think you will be happy. I am positive it will not trash your system since I have used it for quite a while without issue. See my github Readme.md file for security setup instructions. https://github.com/pageauc/pi-timolo/ or go to the developers site for instructions as well.

I would not recommend compiling this from source.

Let me know your results

Regards Claude ...
Last edited by pageauc on Sat Mar 05, 2016 3:12 am, edited 1 time in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by NablaMetal » Mon Aug 17, 2015 11:02 am
Thanks, I'll give it a look and tell you about.

EDIT : It seems that it's aimed to be used only with PiCamera ?
EDIT2 : OK I did post too quick. Gdrive is a program within a bigger project using PiCamera...
EDIT3 :
Code: Select all
sudo gdrive ls
seems to be working like a charm !!
--
NablaMetal
Posts: 4
Joined: Wed Aug 12, 2015 3:12 pm
by pageauc » Mon Aug 17, 2015 11:33 am
See my sync.sh script for a method of initiating a sync only when required (new files) and also avoid launching multiple sync processes. Currently this uses push only but push/pull could also be used. Using a sync.sh type script can avoid unnecessary hand shaking and problems with multiple sync process running at the same time. This has worked well for me in using a crontab and can be adapted for other projects or purposes. You could for instance have a watch process check a folder for changes and then initiate a sync at a specific threshold (eg num new or changed files, num megabytes, Etc)
Regards Claude ...
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by NablaMetal » Mon Aug 17, 2015 12:19 pm
Ok after some investigations, this is what I need.

Unfortunately I am not a shell script guru, and if I understand correctly gdrive, I need to create my own scipt sync.sh to perform what I want.

Since I'm not using it for the PiCamera (pi-timolo) project, the original sync.sh does'nt fit. I modified it to check If it can upload a folder, and it worked. But I haven't managed to perform a real push (it won't delete remote missing files, but only add local missing files ).

Maybe it's not very clear, but I would like my Drive remote folder to be 'slave' and my local Raspberry folder to be 'master'. (one way full sync)

Have you an idea of what should the script looks like ?

Thanks,

--
NablaMetal

EDIT: I just saw you posted something while I was writing this.
EDIT2 : Nevermind, I will try harder and find a way to write my own sync script
Posts: 4
Joined: Wed Aug 12, 2015 3:12 pm
by pageauc » Mon Aug 17, 2015 1:34 pm
Actually if you just want to slave the internet drive folder with the rpi folder the existing push script will do that. It is triggered to push when it sees a pi-timolo.sync file but this requirement can be removed if desired. I put this in to only sync when pi-timolo has new new image files ready.

You can also do a push and pull to sync both folders. The push will put any new or changed files up to the internet google drive and the pull will bring down any new or changed files from the google_drive. If you type gdrive with no parameters you will see all the available parameters. Note deleted items will be put in trash and can use up space if not cleaned up on both the RPI and the internet google drive.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by NablaMetal » Mon Aug 17, 2015 3:09 pm
Actually if you just want to slave the internet drive folder with the rpi folder the existing push script will do that. It is triggered to push when it sees a pi-timolo.sync file but this requirement can be removed if desired. I put this in to only sync when pi-timolo has new new image files ready.


Yes, that's exactly what I did, I removed the line with the rm pi-timolo.sync and change the folder variable. But still it won't delete files on google drive if it doesn't exist on the RPi, it will only add the one that actually are on the RPi and missing on google drive.

--
NablaMetal
Posts: 4
Joined: Wed Aug 12, 2015 3:12 pm
by latimeria » Mon Aug 24, 2015 10:10 pm
Yes, that's exactly what I did, I removed the line with the rm pi-timolo.sync and change the folder variable


Hello,
can you please help me? I'd also like to use this sync.sh script not with pi-timolo
if my media files are in /home/pi/media should I have to change
Code: Select all
SYNC_DIR=motion
with
Code: Select all
SYNC_DIR=/home/pi/media
?
in sync.sh which are the lines to modify?

many thanks
Posts: 242
Joined: Sat Jan 31, 2015 1:47 pm
by pageauc » Mon Aug 24, 2015 11:20 pm
sync.sh reads the current folder that it is in, then assumes the sub folder is in that directory. The line that detects the current folder that sync.sh is in is
Code: Select all
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

You could simply copy sync.sh to /home/pi/ then set
Code: Select all
SYNC_DIR = media


The other way would be to simply leave sync.sh in any folder and remove the line after DIR= and replace with
Code: Select all
DIR=/home/pi
and set
Code: Select all
SYNC_DIR = media


either way would work as long at the google drive authorization hidden folder is in the folder.

Another way is to make a soft link in the pi-timolo folder
Code: Select all
cd ~
cd pi-timolo
ln -s /home/pi/media media


This will create a link that points to the source folder in /home/pi/media and acts just like it actually exists in /home/pi/pi-timolo/media except the media will be a symbolic pointer to the read location.

There are often many ways to do things

Regards Claude ...
Last edited by pageauc on Sat Mar 05, 2016 3:07 am, edited 1 time in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by jor_22 » Thu Feb 18, 2016 5:39 am
Hi there,
Thanks for the GDriveFS steps. I'm having trouble with the very last step: creating a mount that gets connected on boot. I've edited /etc/fstab as indicated, but the gdrive folder does not populate after a reboot until I manually enter the command: sudo mount /mnt/gdrivefs

Is there a way to have the gdrive folder automatically populated after reboot? Thanks!
Posts: 2
Joined: Thu Feb 18, 2016 5:34 am
by pageauc » Thu Feb 18, 2016 2:44 pm
It all depends on what you are trying to mount. Are you trying to mount an external usb drive/device and if so what format is it (fat32, ext4 Etc.) Is it a remote share on another computer? or do you just want to mount another part of the RPI file system onto another part of the file system. Each one is slightly different. I am assuming your mount point works because obviously you can mount it manually. I expect it is a timing issue that is preventing the fstab entry from mounting during boot. Probably the resource is not available during that sequence in the boot process. You may have to delay or retry the mount to a later time using a script. Here is one for a NAS drive http://raspberrypi.stackexchange.com/questions/27179/automatic-mounting-of-nas-drive-fails There are also issues with USB drives etc. You should be able to google a solution depending on what you are trying to mount. Let me know specifics and I will see if I can help.
Claude ..
Last edited by pageauc on Sat Feb 20, 2016 11:44 am, edited 1 time in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by jor_22 » Sat Feb 20, 2016 5:12 am
Thanks Pageauc, you were exactly right. I was trying to mount the google drive files from google's server, and the wifi/network was not yet up. Your link helped me through it - creating a /etc/init.d/mountscript worked for me. Thanks again!
Posts: 2
Joined: Thu Feb 18, 2016 5:34 am
by bobdotexe » Mon Mar 21, 2016 11:25 pm
pageauc wrote:I have had problems with a previous program called gdriveFS. per post above, I have found a much better solution IMO that is documented in my github repo. This solution does not require any dependencies and works out of the box. Details are in my Readme.md under heading setup gdrive sync. Here is my github repo where you can download file. For convenience I have named the file gdrive.
https://github.com/pageauc/pi-timolo/tree/master/source

Let me know your results

Regards Claude ...


It works fine when compiled from source, just uses up a ton of space, and time :P

anyway, here's the latest version:
v0.3.5(Encore)
http://www.mediafire.com/download/439bq3bcbdgd8bn/drive
md5: 462e5b2ccf9ad4b98dde5c7cdaede17d
(compiled on RPi3

as for the setup,
just run:
Code: Select all
drive init ~/gdrive

(replace '~/gdrive' witht he patch to the folder you want to sync)

That will give you a URL you'll need to go to to get your google api key.
once you go there, you'll get annother key,
paste that into terminal, and press enter.

And to run any commands like syncing, you have to be inside that folder:
Code: Select all
cd ~/gdrive

For info on how to use all the other commands, I'd suggest reading here:
https://github.com/odeke-em/drive#usage
Posts: 2
Joined: Thu Apr 12, 2012 4:50 pm
by bitmaster2000 » Wed May 18, 2016 2:11 pm
Just for reference, this is how I've setup gdrivefs (as user "yourname") using proper permissions to restrict access per user. Following the method below, only user "yourname" can access both the credentials file and the mounted Drive folder, and you'll be prepared to be able to add secondary Google accounts for you or other possible users on Raspbian. Just make sure that you:

• Replace username "yourname" with your Raspbian username (the default is "pi"), and then run the commands as that user.

• When you intend to add multiple Google accounts: give each mountpoint (each gdrive mounting directory) and each credentials file (like gdfs.creds) a proper name, something to recognize. For instance: you'd change "gdfs.creds" to "gdfs-yourgooglename.creds", and you'd change "/media/yourname/gdrive" to "/media/yourname/gdrive-yourgooglename". That way, multiple mountpoints and credential files can coexist. Personally I'm only naming secondary accounts this way.

So first, for the sake of information completeness, like the main article I did:
Code: Select all
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip install gdrivefs

I created a hidden directory in the user's home for the Drive credentials to be generated in:
Code: Select all
mkdir -p ~/.gdrive

I've pasted this command's output URL in my browser to permit Google Drive access:
Code: Select all
gdfstool auth -u

...and then I've copied and pasted the given key back in this command:
Code: Select all
gdfstool auth -a ~/.gdrivefs/gdfs.creds "paste_key_here_in_quotes"

Then I secured the permissions for the credentials file that was generated, so that only the current user can access it:
Code: Select all
chmod 600 ~/.gdrive/gdfs.creds

I created a mountpoint for the drive:
Code: Select all
sudo mkdir -p /media/yourname/gdrive

I've set permissions and ownership for the mountpoint (permissions are given at mounting time, but I like to make sure, even when its empty...):
Code: Select all
sudo chmod 700 /media/yourname/gdrive
sudo chown yourname:yourname /media/yourname/gdrive
At this point you can mount your Drive with the command (replace "yourname" again):
Code: Select all
gdfs -o umask=007,uid=`id -u`,gid=`id -g` ~/.gdrive/gdfs.creds /media/yourname/gdrive
As you may notice, I've automated the fetching of the corresponding user and group id's from the user it is executed for.

If the drive is mounted (check: ls /media/yourname/gdrive), it works.

You may want to automate the mounting of your Drive at boot time. You can do this by adding the following to the bottom of /etc/rc.local to run the mounting command as a user (again, replace "yourname" twice):
Code: Select all
# Mount Google Drive as file system for user "yourname" (using gdrivefs)
sudo /bin/su -c "gdfs -o umask=007,uid=`id -u`,gid=`id -g` ~/.gdrive/gdfs.creds /media/yourname/gdrive" -s /bin/sh yourname
In this way, permissions and ownership should automagically be set for the user. Other users on the system should not be able to access it; however, if security is this important to you, you may want to test it to make sure.

Note if you need groups permissions (if you're not sure, then you don't): The umask of 007 basically sets the file permissions to 700. If you use groups, changing the umask to 077 will basically set the file permissions to 770, but in that case you probably want review the 'gid' in the command too. There's probably not one Raspbian owner on earth who uses groups for users, but you may still need to use groups for other things (e.g. for giving download tools like transmission-daemon separate access to external drives).

Needless to say (but saying it anyway as a reminder): it'd be wise to not keep using the default user login and password for your Raspberry, and review any SSH root access, if you're wanting to keep your Google Drive files a bit safe(r).

Regards,
Albert
Posts: 2
Joined: Sun Aug 23, 2015 12:20 pm
by OcoBri » Mon May 30, 2016 5:28 pm
When following the steps here: https://www.raspberrypi.org/forums/view ... 97#p801697
I get an error "403 Forbidden".
Has it moved?
Posts: 10
Joined: Sun May 15, 2016 2:59 pm
Location: Manhattan Chinatown, NYC, USA
by pageauc » Mon May 30, 2016 9:07 pm
I just tried the wget and it works fine. The web site may have had issues when you tried. Try again. It should work since I downloaded OK just recently
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by Ruckus » Tue Jun 07, 2016 1:48 am
Been playing with this over the weekend, worked fine (mostly) and set about backing up my documents with rsync.

Today i got an email saying that someone from Turkey (i am in Costa Rica) had my google password and attempted to log in but Google had stopped it.

Just a coincidence?
Posts: 1
Joined: Wed Oct 30, 2013 6:35 pm
Location: Cairo & Washington DC
by davidcoton » Tue Jun 07, 2016 11:50 am
Ruckus wrote:Been playing with this over the weekend, worked fine (mostly) and set about backing up my documents with rsync.

Today i got an email saying that someone from Turkey (i am in Costa Rica) had my google password and attempted to log in but Google had stopped it.

Just a coincidence?

More likely a spam email, trying to get your Google password out of you through a fake link.
DO NOT click any links in that email.
If you think the email could be genuine, connect to Google through your browser and change your password.
If you have clicked email links, change your password IMMEDIATELY as above, and contact Google. Assume your Google account is compromised.
"If it ain't broke, fix it until it is."
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”
The Pink Unicorn is a symbol of commitment to sensible future versions of the Raspberry Pi ™
User avatar
Posts: 1915
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
by bobdxcool » Mon Sep 26, 2016 11:33 am
pageauc wrote:I have had problems with a previous program called gdriveFS. per post above, I have found a much better solution IMO that is documented in my github repo. This solution does not require any dependencies and works out of the box. Details are in my Readme.md under heading setup gdrive sync. Here is my github repo where you can download file. For convenience I have named the file gdrive.
https://github.com/pageauc/pi-timolo/tree/master/source

You can also download this file from the original developer github per the following
Code: Select all
cd /tmp
wget https://github.com/odeke-em/drive/releases/download/v0.2.2-arm-binary/drive-arm-binary
chmod +x drive-arm-binary
sudo cp drive-arm-binary /usr/local/bin/gdrive
cd ~
gdrive version


I have found the pre compiled gdrive works very well and gives good control using push or pull to sync specific folders. Therefore you can avoid a two way sync that can sometimes be problematic. Anyway give it a try and I think you will be happy. I am positive it will not trash your system since I have used it for quite a while without issue. See my github Readme.md file for security setup instructions. https://github.com/pageauc/pi-timolo/ or go to the developers site for instructions as well.

I would not recommend compiling this from source.

Let me know your results

Regards Claude ...


Hello. I am trying to install gdrive on my pi 3. I have software motion recording videos to a folder. I want to sync this folder to gdrive. So, basically to keep it simple I just download your entire pitimolo application and run the install script which would install gdrive along with other stuff which I dont need. And then I would run gdrive as per the instructions in your repository readme file and modify your bash script to sync . Are any other prerequisites required to be installed?

I actually tried to use gdrive as per the instructions in this blog, http://raspberrywebserver.com/serveradm ... drive.html

But since authentication API has changed by google, it doesnt work.
Posts: 84
Joined: Sun Apr 14, 2013 12:41 pm
by pageauc » Mon Sep 26, 2016 12:26 pm
gdrive has no dependencies and explanation of sync.sh

gdrive runs with No dependencies so all you need is to download the file. You could extract the commands from the install script but here is the simple way to install from a console (for future reference since you already used pi-timolo install script).
Code: Select all
cd ~
wget -O gdrive -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/gdrive
sudo chmod +x gdrive
sudo cp gdrive /usr/local/bin
rm gdrive
 

See my GitHub wiki for more information here https://github.com/pageauc/pi-timolo/wiki/Instructions-to-Re-Purpose-sync.sh
Also see link to original drive Github project here https://github.com/odeke-em/drive (I named my RPI compiled version gdrive)

You may also want to look at the code in my sync.sh script in the pi-timolo project since it can save a lot of headaches if you decide to sync from a crontab. I implemented this script to avoid duplicate instances of gdrive getting spawned as well as resolving possible hung process using a timeout feature in the script. The code can be modified to suit your situation. It looks for a marker file per variable
Code: Select all
SYNC_FILE=pi-timolo.sync
from pi-timolo.py to determine if there are changed files to sync so you may have to change that logic a bit to suit what you want. I implemented this feature since there can be a long handshake to compare a large number of files Eg 500, 1000, Etc. gdrive sync takes time even if there are no changed files to so I look for the marker file to avoid unnecessary handshaking time and associated bandwidth Also the folder sync
Code: Select all
SYNC_DIR=motion
specifies the folder to sync and is relative to the location of the sync.sh script per variable
Code: Select all
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. This can be changed to suit as well. If you are familiar with nano editor and a bit of bash scripting you should be fine. It is a great way to learn. I can help if you get stuck.

Let me know if this was useful information

Regards Claude ...
Claude ...
Last edited by pageauc on Mon Sep 26, 2016 8:35 pm, edited 1 time in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm
by pageauc » Mon Sep 26, 2016 4:38 pm
gdrive updated sync.sh to ver 1.6

I have just updated the sync.sh script in pi-timolo github repo https://github.com/pageauc/pi-timolo/tree/master/source
This is version 1.6 and is a bit more flexible if you want to re purpose the script for other sync operations

github wiki instructions here https://github.com/pageauc/pi-timolo/wiki/Instructions-to-Re-Purpose-sync.sh

Let me know your comments
Claude ...
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp
Posts: 160
Joined: Fri Jan 04, 2013 10:52 pm