greptrick.com

Incoherent ramblings of an InfoSec professional

Google Drive Backup Script

A few weeks back I was looking for a solution to push backup files off a linux box and push them to google drive. All I could seem to come across was apps to sync with google drive on linux. While this would have worked, I didn’t really need nor want any of the files in my Google Drive on a linux server. So I decided to write my own. This is my first foray into a python application of sorts, I have been doing development in PERL for most of my career. This is also my first attempt at interfacing with an API, and I couldn’t have picked a better project since the Google API docs are excellent!

The code is published on my github account. You will need your own developer API key for it to work since sharing publicly isn’t an option and I haven’t come up with a way to securely pull the API key.

https://github.com/gchetrick/gDriveBackup

Currently you need to create a file with the API information to connect to google drive. Once you have that, initialize with google to proved authorization to your google drive and it will then allow you to specify a file or directory to push up.

Keep in mind I am a admin not a developer so the code will be written as such. I am working on going back to clean it up.

Features in the works:
Define and create a directory in Google Drive to upload to
Add ability to encrypt perhaps using TrueCrypt or gpg (of course this can be done prior to upload too)
Resume uploads
Do proper verification that upload completed successfully.

2 responses to “Google Drive Backup Script

  1. Mike S 2013/05/07 at 16:16

    Clever blog name and script. Hope things are going well.

  2. Jeff Blanchard 2013/07/19 at 09:47

    This helped me out a lot; thank you.

    For now I’ve manually created a subfolder and placed the backup in it via:

    body = {
    ‘title’: filename,
    ‘description’: ‘backup via gbackup.py’,
    ‘parents’:[{“id”:”gdrive-folder-id-from-url-here”}],
    ‘mimeType’: format
    }

    Also, the credentials from Google Drive API are via “Client ID for installed applications”, which was not immediately apparent to me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: