The purpose of this tutorial is to demonstrate how to effectively sync the ‘My Documents’ folder using OneDrive for Business without duplication from several computers without the use of Group Policy or any additional software. An example use case of this setup is a person working on a document on a home computer saving the document to their local Documents folder. The document then being automatically uploaded to OneDrive for Business and subsequently downloaded onto their work computer without any user interaction.
Requirements
- OneDrive for Business (OneDrive Personal will only work for a limited number of file types)
- Two or more Windows machines
Limitations
- OneDrive for Business will only sync up to 20,000 files with a 10GB limit for any single file
- OneDrive for Business does not sync non-alphanumeric characters in folder names and files (\, /, :, *, ?, “, <, >, |, #, %)
- For a full list of restrictions, please read this article: https://support.microsoft.com/en-gb/kb/3125202
- OneDrive Personal will only sync Office documents, PDFs, ZIP archives and media files – all other file types are blocked
- You will need to save your work for it to be mirrored – I don’t think OneDrive can sync temporary files or files which are open in another application
Procedure
This doesn’t have to be done on all machines at the same time as long as the steps are followed in order.
Step 1: Start OneDrive for Business by Syncing your directory
Start by opening your OneDrive folder on Office 365 and clicking the Sync button to create your OneDrive for Business folder on your computer. If you’re using OneDrive Personal, you can skip this step as you probably already have a folder in Windows Explorer.
OneDrive for Business will start a short installation wizard which will set up your folder and explain how to use it.
Step 2: Pause Syncing
Immediately after the setup wizard, find the OneDrive icon in your taskbar and temporarily pause syncing. At this stage, you can open your OneDrive folder to make sure the directory you’re trying to mirror hasn’t already been created. If it has, delete it.
Step 3: Make Directory Junctions to your folders
Next, find your OneDrive folder and make a note of the path. OneDrive for Business will typically append your Tenant name on to the folder name so you’ll need to insert that into the following commands. Choose the commands below for the folders which you want to mirror and substitute your Tenant name into the correct space:
My Documents
mklink /j “%userprofile%\OneDrive – <TENANT NAME>\Documents” “%userprofile%\Documents”
Desktop
mklink /j “%userprofile%\OneDrive – <TENANT NAME>\Desktop” “%userprofile%\Desktop”
My Music
mklink /j “%userprofile%\OneDrive – <TENANT NAME>\Music” “%userprofile%\Music”
My Pictures
mklink /j “%userprofile%\OneDrive – <TENANT NAME>\Pictures” “%userprofile%\Pictures”
My Videos
mklink /j “%userprofile%\OneDrive – <TENANT NAME>\Videos” “%userprofile%\Videos”
The “%userprofile%” portion above is a Windows variable for the location of your personal files. For instance, the user Jon Snow’s variable might contain the path “C:\Users\Jon.Snow\”. The easiest way to find your Tenant name is to just double click on the OneDrive for Business icon in the taskbar. This opens the OneDrive for Business folder enabling you to copy the directory name from the address bar. Just to be sure that your modified path is correct, test it by opening Windows Explorer and typing the path to your OneDrive folder into the Address Bar as shown below:
If the path is correct, open your Command Line by holding the Windows Key on your keyboard and pressing ‘R’, then typing CMD into the Run window. You can also just type CMD into the start menu search bar. Once you’re in command line, execute each of the commands above with <TENANT NAME> substituted for your tenant name.
The command makes Directory Junctions to your folders inside of OneDrive and effectively creates a browsable shortcut to your files without duplicating them. Once you’ve run the command for each folder you want to mirror, proceed to the next step.
Step 4: Resume Syncing
If you’re performing this on all of your computers at the same time, create all of your Directory Junctions on all of your computers before resuming Sync. Otherwise, if you sync up the directory, you will need to delete it from your OneDrive folder on any additional PC during Step 2.
Resume Syncing by right-clicking on your OneDrive icon and selecting ‘Resume syncing’ from the menu. OneDrive will get to work uploading and downloading files. The process may take a while depending on your Internet Connection speed as well as the amount of files you have.
Step 5: Test
Lastly, when all your files are uploaded you will want to test your setup by creating a file on one of the computers and seeing it mirrored on the other one.
I tested mine by creating a simple text file with the word “Hello” in it.
The file was uploaded to OneDrive and made available on another laptop. Please keep in mind that if you preform this test before all your other folders are completely synced, OneDrive will add your test file to the end of the queue and it may take some time before you see it.