Saturday, December 7, 2013

Google Drive - problem and solution (advanced use case)

Many users have a very common complaint with using Google Drive, which goes along these lines:

I signed up for Google Drive and when I want to sync a folder that already contains files, the program complains that the directory is not empty. But I already have two hundred gigabytes of data in my C:\ABC directory and programs that use that data with that directory hard-coded in. Now if I move all my files over into the Google Drive folder as the Google program wants, I have to re-write all my directory paths in my code again. And if I don't move my programs to the Google Drive folder, Google's drive program won't sync with the cloud. Why can't Google fix this?

See for instance: http://productforums.google.com/forum/#!topic/drive/-TmjPhFSNAY

Thing is, Google doesn't need to fix this. Of course, it would be nice if Google's Drive sync program were able to sync a non-empty folder into the cloud, especially for new accounts. But you as a user are not helpless. A fairly simple remedy exists. This works for both Unix variants and Windows, but this post will cover how to solve this issue in the Windows environment. USE AT YOUR OWN RISK. This worked well for me.

The key to solving this problem is an idea called a hard-link. The way this works, if you create a hard-link from one directory A to another newly created directory B, then this creates a virtual copy of the directory A in B. In other words, C:\A and the newly created C:\B point to the same contents (namely the files and folders under C:\A), and any updates made to C:\B\abc will be reflected in C:\A and vice-versa. Hard links are also sometimes called "junctions" in Windows parlance.

Now, how to solve the problem in italics from above? Until Google fixes their Drive program to be able to sync any non-empty folder(s) into the cloud, what you can do is:

  1. backup the data you want saved into the Google Drive (C:\ABC) to an external hard drive device
  2. install Google Drive, set a location for the Google Drive folder or stick with the default proposed location
  3. move (do not copy) C:\ABC to Google Drive folder from (2) above
  4. the Google Drive program is happy with this, and starts sync'ing the files and folders to the cloud
  5. wait for the move in step 3 to complete. verify that it was completely successful. then delete (remove directory) C:\ABC.
  6. create a hard link between the Google Drive folder from (2) above, and C:\ABC. this step will only work if the C:\ABC drive was completely removed in step 5. 
  7. Google Drive will now sync all your files, and your programs that were hard coded with the C:\ABC path will continue to work.
So now we need to discuss how one might create a hard-link to a directory in Step 6 above. This is easily done as follows: 
  1. Open a command prompt as administrator (right click on your command prompt icon in the Start Menu, then pick "run as administrator"). 
  2. type in "mklink/?" in the command window and hit enter. this will show you the various options or switches you can use with this command.
  3. to create a hard link to a directory, you need to use the following syntax: "mklink <link> <target>". if there are spaces in either of your directory names, you need to use quotes around it (as usual). So for instance, here you are creating a hard-link between your target directory of "C:\Google Drive" (or whatever drive name you picked for the Google Drive, and C:\ABC (which now doesn't exist on disk anymore). So you type: mklink C:\ABC "C:\Google Drive" and hit <enter>. This creates a "junction" or hard-link.
... and you are done.


So how do you delete a hard-link? Deleting a directory hard-link is the same as deleting a directory in Windows. Simply type "rmdir C:\ABC" at a command prompt, and hit enter. Remember, you specify the link directory, not the Google Drive directory, in the command above. This way, your data still exists, just the link is removed.

Interesting links for comparison of various cloud drive services:
http://macography.net/2013/05/speed-test-dropbox-google-drive-box-skydrive-amazon-cloud-drive/
http://www.theverge.com/2012/4/24/2954960/google-drive-dropbox-skydrive-sugarsync-cloud-storage-competition

No comments:

Post a Comment