November 25th, 2012
So here is the scenario, you have multiple computers, a laptop, a desktop, perhaps even a workplace computer. You have files, on all of these devices, and you have figured out that the best way to access your home files at work, or your work files at home (hopefully not too often) is to use a cloud hosting solution. And, why not? They are almost commonplace now between Google Drive, Dropbox, OneHub, Box, and Amazon just to name a few are reliable, fast and user friendly. Long gone are the days of carrying around and loosing USB drives the cloud is being embraced by everyone. The only downside to these solutions is that none of them are perfect.
Lets talk about some of those major flaws. Google Drive and Dropbox are notorious for their sync agents just quitting or exiting quietly in the background. This can be aggravating when in an area with no internet access, you thought you got that last sync in right, nope wrong. How about the fact that you actually have to manually sync, or the lack of the ability to setup a schedule sync in the future. Finally the dreaded message “19 of your 298 files can not be synced”, but why, oh why? These issues can cause even an expert to start pulling out their hair.
So here is the ideal situation, taking your cloud based storage and putting your home folder in the cloud. This will allow you to sync multiple computers together and keep them in sync. For example you have a text file on your desktop, you edit it and it magically shows up on your laptop’s desktop. iCloud… please, this can be done very simply and with a few scripts we can schedule synchronizations, we can keep those agents from quitting randomly and we can ensure that all the files sync without incident.
Moving the home folder in the cloud
Its worth noting that I am only advocating that you move the Desktop and Documents folder to the cloud, the Library should never be moved to the cloud ever, and your Music and Movies can be moved as long as you are not afraid of the price tag of storing these in the cloud. So lets use Google Drive as the example for this article although you can apply these concepts to any cloud based storage solution.
sudo mv rm -r /Users/Your User Name/Desktop /Users/Your User Name/Desktoptemp && /Users/Your User Name/Documents /Users/Your User Name/Documentstemp
This command simply renames your Desktop and Documents folder, so that you don’t loose any of those files.The next step is for you to install and configure Google Drive on your computer. Once you have it installed you need to make sure that its fully synchronized. Create a folder in your Google Drive folder called Desktop and Documents. Again these concepts can be translated to any cloud based sync solution.
sudo rm -r /Users/Your User Name/Desktop /Users/Your User Name/Documents && ln -s /Users/Your User Name/Google Drive/Documents /Users/Your User Name/Desktop && ln -s /Users/Your User Name/Google Drive/Desktop /Users/Your User Name/Documents && killall Finder
This is a loaded command, first it removes the local Desktop and Documents folder which you should no longer have since they were moved to the temporary location. Then we are creating a link from the Google Drive Desktop & Documents folder to the respective locations in your home folder. Finally we are restarting the finder. At this point any files you move to Desktop or Documents will be sync’d with Google Drive. Move any of the files from the Desktoptemp and Documentstemp folder to their respective locations i.e.: Desktop & Documents and watch it all start syncing to the cloud.