How I Use Google Drive to Back Up My Files

eBooks on sales: Creative Retouching Essentials in a Day || Digital Photo Retouching: Beauty, Fashion & Portrait Photography

UPDATE: the Google Drive apps are now available on the App store and GooglePlay. Some screen shots below.

If you’re a die-hard Google fanboy like me, then you should have already known that Google just released Drive, also previously known as Docs. If you’re not a Google fanboy, well, then it’s official: Google Drive is live. Google Drive is kind of like Dropbox and other online storage services, but it’s better, simply because it’s a Google product. Why? Everything I do is now integrated with Google across the board. What’s nice is that if your file format is supported by Google Docs Drive, you can open the file online without using Microsoft Office software or PDF reader.

While the service is new, the interface isn’t really different than what you used to see in Google Docs. The only huge difference is now you have a whopping 5 GBs of storage at your disposal. Dropbox wasn’t an option for me due to its initial limit of 2 GBs, and I didn’t want to spam my friends and family to get my box to increase its size. All of my most important documents rack up to about 2 GBs, including my Facebook archived data when I left it. Google Drive is the best solution for my personal data backup. I only wish the service had gone live sooner.

I spent a few minutes to create a batch file that gets run every Wednesday and Sunday at 11pm. All my important documents are mirrored into a location, which is synchronized with Google Drive. The batch file only works with Windows machine. If you have a Mac, well, I’m sorry that you’re stupid different.

@echo off
start "Google Drive Sync" "C:\Program Files (x86)\Google\Drive\googledrivesync.exe"
robocopy "D:\'B' Data\Documents" "D:\'B' Data\Google Drive\Documents" /S /MIR /R:3 /W:1 /LOG:"D:\'B' Data\mirror_drive.log" /NP
robocopy "D:\'B' Data\Work" "D:\'B' Data\Google Drive\Work" /S /MIR /R:3 /W:1 /LOG+:"D:\'B' Data\mirror_drive.log" /NP
IF %ERRORLEVEL% GTR 7 MSG * "Something went wrong with mirroring Google Drive. Check log!"

First, I tell the batch script to not display anything in the console by issuing the command

@echo off

Then, I start up the Google Drive desktop client. I have a 64-bit operating system, hence the (x64) part. Thanks to a small tip from a commenter, I’m able to start the client without having the console freeze (it did this with my previous version of the script).

Update: with Windows 7 and Task Scheduler, when you use the below command, the googledrivesync.exe process will be run under the user ‘System’, so unless your go and kill it, it’ll run in the background until you restart your computer.

start "Google Drive Sync" "C:\Program Files (x86)\Google\Drive\googledrivesync.exe"

Next, I issue a copy command from the source folder to the destination folder. The destination is what’s synchronized with Google Drive.

robocopy "D:\'B' Data\Documents" "D:\'B' Data\Google Drive\Local" * /S /MIR /R:3 /W:1 /LOG:"D:\'B' Data\mirror_drive.log" /NP

There are a few parameters to the command:
/S: copy all folders and subfolders
/MIR: mirror. If the source folders are removed, then remove the destination folders
/R:3: retry 3 times before giving up the mirroring
/W:1: wait for 1 second between each try
/LOG:file: specify where to log the copy command
/NP: No Progress – don’t display % copied in the log

I have a check at the end of the script. If anything goes wrong during the mirroring for some reason, I will be notified with a message box, telling me to look at the log.

IF %ERRORLEVEL% GTR 7 MSG * "Something went wrong with mirroring Google Drive. Check log!"

You can find more info about robocopy exit codes HERE.

One thing that I have beef with the Google Drive desktop client is that it doesn’t offer any command line option. I do want to run the mirroring and the synchronization at least twice a week, but I don’t want the client to run in the background. For now, I’ll just have to let it run for a few minutes before it finishes, and then I’ll kill the client. I hope Google’s working on updating the software.

Another major bug I’ve found with the client is that rather than checking the files for their hash values, I think Google Drive client checks for the timestamps, which is what robocopy already does. So, things could really get out of whack if, say, you remove a folder within your Google Drive local folder for robocopy to resync. Instead of resynchronizing, Google Drive client will make a new folder on the server, thus having 2 folders with the same exact content on Google Drive. Hello Google, have you guys heard of MD5 checksums?

That’s it. This is how I use Google Drive to backup my important files, and how I automate the process. If you have any questions or comments, feel free to drop a line below. You can head over to Google Operating System blog to read more on Google Drive.

photo 1 580x870 How I Use Google Drive to Back Up My Files Tam Nguyen New Nork Portrait Fashion Photographer

photo 2 580x870 How I Use Google Drive to Back Up My Files Tam Nguyen New Nork Portrait Fashion Photographer

Share this on:
Share this on Facebook Share this on Twitter Share this on Google Plus Submit this on Digg Bookmark this on Delicious Submit this to StumbleUpon Submit this to Reddit Send this via email
  • Jason

    Thanks for the idea/script Tam.

    To launch the Google Drive client automatically use the ‘Start’ command, eg.:
    start “Google Drive Sync” “C:\Program Files (x86)\Google\Drive\googledrivesync.exe”.

    • http://tambnguyen.com Tam Nguyen

      Thank you for the tip. I did think of that, but for some reason I was missing the “title” argument for my START command, so it wasn’t working right. Duh!

  • Robert

    Hi
    saw your comments and I am interested to know if I can use Symantec Backup Exec to ftp my backup to the google drive ?

    Thanks

    Robert

    • http://tambnguyen.com Tam Nguyen

      It depends on the size of your backup. Per Google (http://support.google.com/docs/bin/answer.py?hl=en&answer=37603), the maximum file size is up to 10 GB per file. As the time of this writing, there is no way to FTP your files to Google Drive, so you’ll have to use the client to sync your files.

    • pabloto

      I use Cobian Backup to copy my backup to local folder google drive. I needed to stop synchronizing and back in to keep the backup error but with this perfect!

  • http://www.mapified.com Steven Benjamin

    What does the ‘B’ mean?

    Thanks

    • http://tambnguyen.com Tam Nguyen

      It’s just my way of naming my folders. I name them with the ‘A’ and ‘B’ and stuff so that they appear in the order I prefer.

  • asma

    how to pause data if we shutting down system in between?