Home Tech Geek Desktop How to Download Large Files from Google Drive Without User Intervention

Get social!

Google DriveI use Google Drive for all my important stuff, and for the files I need access to remotely. It's cheap, and though not perfect, good enough. One stumbling point had been the fact that Google Drive doesn't support the Linux desktop environment. I overcame that by using isync, a nice app that works similar to the Google Drive client, and on Linux.

I also use KeePassX to store my passwords. The program really helps secure my online persona -- as much as possible, anyway. The problem I was experiencing was that MiniKeePass (a mobile app for KeePass) would not open my password database on my new iPhone. It worked on my old one, but the program kept barfing on the new phone. On top of that, MiniKeePass doesn't sync your database file (when using Google Drive), so if you make changes to it, you have to re-download the file from Google Drive to your phone, a time-consuming and irritating task.

The answer? WebKeePass! This app lets you pull up your KeePass database from a browser. Setting it up took awhile, so that's a story for another post. At any rate, once I got the program running on my Linux server, and viewable in my mobile browser, the only thing left to do was to occasionally download a fresh copy of the database from Google Drive (I wasn't running isync on the server computer, just my local desktop). Turns out this isn't as easy as it sounds.

First, I tried using GDrive, a Google Drive command-line client. It was able to download the file, but would prompt me to create a new auth token every once in awhile, which was unacceptable, since the process had to be automatic. So I grabbed the URL link to the file and tried using a simple wget command to retrieve. Uh-uh. When a file is over a certain size, Google alerts the user that the file is too large to scan for viruses before allowing the download. I then tried gdown.pl to overcome this limitation, but it also failed to do the job as well.

So, as I often do, I rolled my own solution. It is quite simple, does almost no security and error checking, but works nonetheless (just the way I like my scripts). I call it google-drive-large-file-downloader.py. Here it is (all 23 lines of it):

I call it with a simple shell script that I added as a cronjob, and the database now gets updated once per day. You could easily adjust the frequency of the update to suit your needs, of course.

I should note that this solution is a one-way sync, and viewing the KeePass file on my mobile devices is a read-only experience. While not perfect, it certainly does the job I need, and hopefully you will it useful as well!

Hey, I've started a GitHub repository of all the useful utilities I've created over the years. Yes, I know, the above script is the only file in the repository so far (hey, I'm busy, I'll get to adding more). Here's the link:

https://github.com/drodrig/utils

I hope to add more files as time allows.

Leave a Reply

Bad Behavior has blocked 55 access attempts in the last 7 days.