Skip to main content

How to Back Up Google Drive to a Raspberry Pi

Yes, you read that direction correctly: this is a how to covering backing Google Drive up to a Raspberry Pi, not the other way around.

For the impatient, here's a link to the scripts on GitHub, but it'll probably help put things in context if you at least skim the rest of this post since there are a couple of dependencies in the mix.


I do volunteer tech work for an organization that, like many organizations, uses Google Drive heavily, and doesn't have much money to throw around. This organization's Tech Committee has discussed whether or not we need to have a backup of the Google Drive files numerous times, but we keep kicking the can down the road since Google Drive versions files and retains trash until someone empties it, lessening the necessity of having a backup.

But, catastrophes happen. If someone were to delete all the files and empty the trash, you do have 25 days to contact Google and they can try to get your files back for you. Alternatively, you could hope someone has a copy of everything on their local machine. I'm sure some folks do, me being one, but crossing one's fingers does not a good backup policy make, and if someone is frantically looking for a file, I'm not sure I want to have to contact Google to hunt it down. Plus this seemed like a fun little project.

Another alternative if you want to spend some money would be to use one of the services that will backup Google Drive to another cloud storage. In my situation we didn't want to spend any budget on this, and we didn't want to make it a task someone had to remember to do manually. Since I have a few Raspberry Pis laying around I decided to take a run at coming up with a solution I could just have running quietly in my house that would cover us in the event of a disaster.

Requirements and Constraints

The requirements/constraints I placed on myself were as follows:
  1. It can't cost any money other than the cost of the Raspberry Pi and SD card. (And since I have several I'm not using, this was "free.") I do cheat just a hair on this point in a couple different ways; see below.
  2. It can't take me an inordinate amount of time to set up since I have a million things to do. So while digging into the Google Drive API and rolling my own solution from scratch sounds like fun, now isn't the time for me to do that, so I was looking for solutions that will do as much of the work for me as possible.
  3. Since the Raspberry Pi is going to be sitting on a shelf somewhere not hooked up to a monitor, I'll need some sort of notification that the backup worked, so if I don't get notified I'll know something's up. This doesn't need to be fancy, I just need to know it's working.
  4. This is a last resort backup, so I'm not going to be doing any fancy file versioning or anything along those lines. The sole intent for this is to have a backup of the files if none exists anywhere else.

Step One: Configure the Raspberry Pi

Since I hadn't messed with Raspberry Pis in a while and wasn't sure what state the operating systems on the ones I have were in, I just grabbed one with a 64GB SD card and started from scratch.
  1. Download and install Etcher if you don't already have a program you use to write images to SD cards
  2. Download Raspbian
  3. Use Etcher to write the Raspbian to the SD card
  4. Stick the SD card in the Raspberry Pi and boot it up
This should get you to a desktop. (If you don't have a monitor, keyboard, and mouse and need to launch headless, you can read about how to to that here.)

Next, we'll want to install some updates and configure the Pi.
  1. Open a terminal
  2. sudo apt update && sudo apt upgrade
  3. sudo raspi-config
    1. You can change whatever settings you want here (root password, etc.), but the critical one is to make sure the clock sets from the network on boot, so ...
      1. Select "Localisation Options"
      2. Change Locale as appropriate
      3. Select "Change Timezone" and set your timezone
    2. You'll also likely want to go to "Advanced Options" and select "Expand Filesystem" so the OS will use your whole SD card (I'm not using an external hard drive in my setup; I just stuck a 64GB SD card in there which will be plenty to backup what I need)
    3. I had to change my keyboard layout from the default British layout to American; if you try to type an @ and see # instead, that's a telltale sign you're in the same boat.
    4. Since I may have multiple Raspberry Pis on my network soon I changed the hostname to something specific to this task.
    5. Choose "Update" to update the config tool to the latest version
  4. Reboot the Pi

Install and Configure overGrive

This is where I cheated one of my constraints but met another. overGrive is a Google Drive client for Linux, and since Google doesn't officially support one anymore, this one cost $5. That said, this also saved my tons of time so I met that aspect of my goals, and I don't mind at all supporting people who build useful tools such as this.

Basically what the solution winds up being is I'll use overGrive to sync the specific folder from Google Drive I want to back up, and then I'll use good ol' rsync to copy the files to another directory, thereby having a backup of what's on Google Drive no matter what someone does to the files online.

Basically all you need to to for this step is follow the installation instructions here. It worked without a hitch for me.

Once overGrive is installed, do the following:

  1. Click on the Raspberry menu, then "Accessories," then "overGrive"
  2. Click "OK" on the "Setup Required" screen
  3. Click "Connect account" -- this will open up a Google login screen in a browser
  4. Log in with the Google account that has access to the Google Drive you want to back up. NOTE: overGrive does not seem to support "Shared With Me" Google Drive folders, so you'll want to use the Google account that owns the files you want to back up.
  5. Accept the overGrive permissions
  6. Copy the code on the screen that reads "Please copy this code, switch to our application and paste it there"
  7. Switch back to the overGrive settings application
  8. Paste the code into the "Copy and paste the Google Drive Authentication code here" box
  9. Click "Validate"
  10. Click "Activate" if you bought an overGrive code, or click "Continue" if you want to try it out free for 14 days
  11. At this point you're back on the "Setup Step 2 of 3" screen. Here, since I only want to back up one folder, I clicked the "Only sync certain folders to this computer" option and chose the folder I want to back up.
  12. Make sure "Auto Sync" is checked so overGrive will automatically stay in sync with changes on Google Drive.
  13. Click "Start Sync." This will, as the button says, start the files syncing. According to the overGrive documentation it's important that you let this finish so if you have a lot of files, this might be a good time to call it a night and check on things in the morning, when we'll deal with the script to do the actual backup and send notifications.

The Backup and Archive Scripts

The "backup" concept I'm using for this little project is a rather braindead but effective one for my needs: copy the files from the directory that syncs with Google Drive to another directory, thereby having a copy of the files detached from Google Drive so if disaster strikes, we have an isolated copy.

To cover the unlikely scenario of perfect timing whereby the directory is empty when the directory sync happens, I'll zip up a copy of everything nightly and set that aside, keeping two days worth of archives. (You could of course keep as many as you want but I'm limiting myself to two days since my SD card is only 64GB, and I didn't want to attach a portable hard drive to the Raspberry Pi for these purposes.)

To provide a bit more detail and put all of this in steps to make it more clear:
  1. Since I'm a Python programmer the backup script will be in Python, and I'll use dirsync (a Python implementation of a robocopy or rsync-type utility) to sync the Google Drive directory to my backup directory. dirsync only syncs changes so after the initial backup we can safely and efficiently run this hourly.
  2. So I know whether or not the sync worked, I'll have the script notify me either way. I thought about having it only notify me if there are errors but if someone kicks the cord out of the Raspberry Pi (I'm looking at you, cats) not getting a notification will tell me something went wrong.
  3. Nightly a script will run that zips up the backup Google Drive directory and puts the zip files in an archives directory. This script will also delete files that are more than 48 hours old.

Brief Tangent: Notifications

I thought about using email for notifications since that's the obvious, easy, lowest-common-denominator solution. But when I do little side projects like this I like to use them as an opportunity to learn something new, so I decided instead to use Pushover and have notifications come to my phone. (I thought briefly about looking into doing a Google Home or Alexa app but that was a bridge too far for this project.)

The long and short of Pushover is it's a service that lets you send notifications to Android or iOS programmatically. So if you want to try this out just sign up for Pushover (they have a 7-day free trial), verify your email address, and then create an app to get the token you'll need to use in the script.

Here again I cheated on the "has to be free" requirement and paid the one-time $5 fee for Pushover on my phone, not only to support them but because I may wind up using this on other similar projects.

Back to the Scripts

Refer to GitHub for the full details, but I do want to highlight a couple of things about the scripts.

First, they're actually totally generic and have nothing directly to do with Google Drive, so the name of the project is probably a bit of a misnomer. overGrive handles the Google Drive sync, and these scripts are really just doing an rsync-style copy from one place to another, and periodically zipping up the results for a bit longer retention. It might be interesting at some future date to make this a truly comprehensive solution and leverage the Google Drive API to do the syncing from Google Drive, but I decided paying $5 for overGrive was a better choice at this particular juncture.

Second, by default the sync script will purge the target directory, meaning files that don't exist in the source directory will be deleted from the target directory. I went back and forth a bit on that point but decided I wanted an accurate representation of the state of the Google Drive at the point at which the sync occurs, and I didn't want deleted files cluttering up the backups. Again, people can always get deleted files from the trash on Google Drive unless someone empties the trash or explicitly permanently deletes a file. This is an easy setting to change if you want it to behave differently.


Raspberry Pi + overGrive + Pushover + some Python = success! I now have a handy setup for backing up Google Drive that all told probably took less time to put together than it took to write this blog post about it. I'd be interested to hear if others have solved this problem in different ways.


masrafi rahman said…
Prioritizing & making anything smooth always senssse the best in any ecosystem. To protect along with run the entire process flows for all mentioned activities works properly. If someone go by the prescribed way then proper research plus authenticity is needed to proof the scenario. Substantial mechanism always shows the true path to make the documents or finished products perfect.
Oscar Edgerly said…
Prioritizing and creating anything at all clean constantly sense the most effective in different ecosystem. To guard in addition to work the complete method runs for many described routines operates appropriately. When an individual pass by the particular click here approved approach next appropriate study additionally authenticity is necessary to resistant the particular circumstance.
Unknown said…
The University may let loads of scholars some hope for his or her study facet. which will facilitate them within all approach for academic propose. click here now and on their website, you'll realize our application that we tend to write in time.
Unknown said…
There has some helpful approach wherever you'll get to try and do your things on writings and listening. visit this link and browse around this web site and acquire the correct author for your personal statement.
tes said…
Sounds like another nice writing to read! My husband and that i would be terribly curious by reading it about the educational topics. In here you will get a lot of data concerning our educational study and prep facet.
amsa leka said…
Thanks for your great and helpful presentation I like your good service. I always appreciate your post. That is very interesting I love reading and I am always searching for informative information like this.iot training institutes in chennai | industrial iot training chennai | iot course fees in chennai | iot certification courses in chennai
kavinilavu G said…
Such a Great Article!! I learned something new from your blog. Amazing stuff. I would like to follow your blog frequently. Keep Rocking!!
Blue Prism training in chennai | Best Blue Prism Training Institute in Chennai | RPA training in Chennai | Best RPA training in Chennai | RPA Training with Placement in Chennai
Rithi Rawat said…
Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.

top institutes for machine learning in chennai
python machine learning training in chennai
machine learning classroom training in chennai
artificial intelligence and machine learning course in chennai
amsa leka said…
Nice blog..! I really loved reading through this article. Thanks for sharing such a
amazing post with us and keep blogging... best angularjs training institute in chennai | angularjs training in omr | angular 4 training in chennai | angularjs training in omr
Carolyn said…
This seems to be some amazing blog post that you have shared here. People at you could try here and I would love to add more to your effort in getting this type of things.
nikitha josh said…
I have gone through your blog, it was very much useful for me and because of your blog, and also I gained many unknown information, the way you have clearly explained is really fantastic. Kindly post more like this, Thank You.
best aviation academy in Chennai
best air hostess training institute in Chennai
airline management courses in Chennai
airport ground staff training in Chennai
Aviation Academy in Chennai
air hostess training in Chennai
airport management courses in Chennai
ground staff training in Chennai

Popular posts from this blog

Installing and Configuring NextPVR as a Replacement for Windows Media Center

If you follow me on Google+ you'll know I had a recent rant about Windows Media Center, which after running fine for about a year suddenly decided as of January 29 it was done downloading the program guide and by extension was therefore done recording any TV shows.

I'll spare you more ranting and simply say that none of the suggestions I got (which I appreciate!) worked, and rather than spending more time figuring out why, I decided to try something different.

NextPVR is an awesome free (as in beer, not as in freedom unfortunately ...) PVR application for Windows that with a little bit of tweaking handily replaced Windows Media Center. It can even download guide data, which is apparently something WMC no longer feels like doing.

Background I wound up going down this road in a rather circuitous way. My initial goal for the weekend project was to get Raspbmc running on one of my Raspberry Pis. The latest version of XBMC has PVR functionality so I was anxious to try that out as a …

Running a Django Application on Windows Server 2012 with IIS

This is a first for me since under normal circumstances we run all our Django applications on Linux with Nginx, but we're in the process of developing an application for another department and due to the requirements around this project, we'll be handing the code off to them to deploy. They don't have any experience with Linux or web servers other than IIS, so I recently took up the challenge of figuring out how to run Django applications on Windows Server 2012 with IIS.

Based on the dated or complete lack of information around this I'm assuming it's not something that's very common in the wild, so I thought I'd share what I came up with in case others need to do this.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Assumptions and CaveatsThe operating system is Windows Server 2012 R2, 64-bit. If another variant of the operating system is being used, these instructions may not work properly.All of the soft…

Fixing DPI Scaling Issues in Skype for Business on Windows 10

My setup for my day job these days is a Surface Pro 4 and either an LG 34UC87M-B or a Dell P2715Q monitor, depending on where I'm working. This is a fantastic setup, but some applications have trouble dealing with the high pixel density and don't scale appropriately.
One case in point is Skype for Business. For some reason it scales correctly as I move between the Surface screen and the external monitor when I use the Dell, but on the LG monitor Skype is either massive on the external monitor, or tiny on the Surface screen.
After a big of digging around I came across a solution that worked for me, which is to change a setting in Skype's manifest file (who knew there was one?). On my machine the file is here: C:\Program Files\Microsoft Office\Office16\LYNC.EXE.MANIFEST
And the setting in question is this:
Which I changed to this: <dpiAware>False/PM</dpiAware>
Note that you'll probably have to edit the file as administr…