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
@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
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.