Google Drive syncing on Ubuntu

Google Drive
Google Drive is a perfect choice for performing web server backups. There’s no official linux client as far as I can make out but fortunately for us there is an open source implementation called “Grive” that does exactly what we want! This is my preferred backup provider currently as it gives 15G of space! Way more space than Dropbox and it seems a lot more stable.

Pre-requisites

Sign-up for Google Drive Api

You will need to go sign-up and enable Drive API on your google account. Generate a Server API Key, providing the ip address of your web server to google when creating it. Then proceed with the steps below.

System Packages

You will need a number of packages installed in order to build grive from source. If you followed my linode installation guide you should have everything you need, but you can run this command anyways just to make sure we did not miss something.

Install & Setup Grive

If that all went well, you should be good to go. Now we need to do the initial configuration, now make a new folder that will house all our synced files.

This will output a web url that you need to copy and paste into a browser. I think the only requirement here is that you are logged into Google under the account you wish to have it be linked to and make sure you have Drive API access enabled before you do this. It will display a validation code that you then need to copy and paste back into the terminal then press enter.

Setup Cron For Unattended Syncing

We need to add a line in crontab to execute grive every minute to sync files. But first we will create a bash script to execute grive. If you are going to set up automatic mysql backups as well (which I outline in another article) you will need it setup this way.

1
2
mkdir ~/scripts
nano ~/scripts/grive.sh

Paste in the following (Obviously replacing your paths to match your system)

Now make it executable

Now we add the crontab entry for it.

Then add this line at the end of the file

That should be it. You should be good to go. Test it by copying a file to ~/gdrive and then verify on the google drive website that the file was synced!

Posted in Server Admin Tagged with: , , , , , , , , , , ,
One comment on “Google Drive syncing on Ubuntu
  1. TJ says:

    PS: Website in progress…

    This API looks useful and pretty cool. I think I will implement it in one of my big projects I am making related to cloud servsers and storage. I am very into server work and admin work.

    TJ

2 Pings/Trackbacks for "Google Drive syncing on Ubuntu"
  1. […] feature goes perfectly with my previous article on Google Drive Syncing. If you pair it with these automatic backups you can have your mysql backups automatically sync to […]

  2. […] I have a newer updated version of this guide on my new blog. It’s very similar but a little different and has a bit more detail, you can read it here. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Sponsored Links