2-Way sync doesn't work in OneDrive when using symbolic links or junctions
I’ve already read a lot about the problems with Symbolic Links and Windows 10 on internet, but not about the phenomenon I run into now. So here it is…
My goal is to 2-way sync a folder (‘My Music’), located on a separate data partition of my SSD-drive, to the OneDrive cloud via a symbol link. It all works fine… except the 2-way syncing. It stays a 1-way street somehow. :-(
Both the data partition and the Windows system partition have the NTFS file system. The data partition has the letter (X:
). I have an existing OneDrive account with no files or folders on it yet.
As far as I understand now, creating a junction is the way to go, although creating a symbolic link could work too in this case. The procedure I followed is this:
- Opened my OneDrive account online.
- Set up OneDrive on my computer.
- Keep the standard location of my OneDrive on the system partition:
C:\Users\<my user name>\OneDrive
. - Opened the command prompt as administrator.
- Created the junction with this command:
mklink /J “C:\Users\<my user name>\OneDrive\My Music” “X:\My Music”
- The
‘My Music’
link appears as a folder underneath the OneDrive icon in Windows Explorer. - Tested if the link with the folder
‘My Music’
on my data-partition actually works. And it does perfectly. - Over to OneDrive online. The
‘My Music’
folder also appeared in my OneDrive online. - Uploaded a random file from my computer into the
‘My Music’
folder to test the syncing. - Uploaded file appears in my OneDrive online.
- Back to Windows Explorer on my computer. The uploaded file has appeared in the
‘My Music’
folder on the data partition via the created link.
So far so good. Anything I upload to my OneDrive online appears perfectly in my data partition folder. But the problem is that the 2-way sync fails. If I change anything in the ‘My Music’
folder on the data partition, that change does appear in the same OneDrive folder that is linked (obviously), but that’s where it stops: no syncing to OneDrive online. How come and what is the solution?
Exactly the same happens if I use not a junction, but a symbolic link: mklink /D “C:\Users\<my user name>\OneDrive\My Music” “X:\My Music”
And my 2nd question is: how is it possible that the result is exactly the other way around, when I change the procedure and first create the junction (or symbolic link) and then set up OneDrive on my computer? So in that case syncing a file to OneDrive online via the created link works fine, but if I change anything in the ‘My Music’ folder in OneDrive online, that change does not appear in the folder on my data partition. Again, it’s only 1 way.
I just don’t get it. Does anyone have the answers please? Thanks in advance!
Solution 1:
Per this thread in Microsoft's forums, it looks like OneDrive was getting notified of file change events from aliased (junction/symlink) paths around 5/31/2017 (see reply marked best response), but on 1/17/2018 somebody reported that they were broken, and the author of the reply marked best response seemed to confirm that.
The later suggestion to "use hard links" doesn't work, as I believe there are no "directory hard links" in NTFS.
Sad to say, I think this is broken right now.
There are a couple mentions of workarounds in that thread -- OneDriveBully to manually trigger a (full?) sync of OneDrive periodically, and generic folder sync utilities to 2-way-sync the two directories (incurring 2x disk space and probably lots of headaches when it has to, ie. handle conflicts). I don't like any of them.
Solution 2:
I would not feel secure putting my Desktop folder on an external drive, since my Desktop will fail to load if the SD card is missing or corrupt. So i prefer to keep Desktop in it's default location on the local C: drive, and just put a junction link to Desktop into the OneDrive folder on the external drive.
Problem is, mklink /J
with external drives doesn’t sync to OneDrive as expected. It won’t sync instantly on file-changes. (other report it used to work, but fails for me as of january 2019).
However, the junction-linked desktop WILL sync when the computer is restarted (or when user logs off and back on). For some purposes, this may suffice.
For example, i only occasionally save files on my desktop, so i put a junction link into my OneDrive folder (which resides on an external SD card). I normally restart the computer at least once per day, so the desktop gets sync'd daily.
(It will also sync when onedrive is paused and then unpaused, but manually pausing/unpausing all the time is not convenient)
For Documents, i want constant syncing immediately on file-changes, so i moved my Documents folder into OneDrive on the external SD. If the SD card is missing or corrupt, my account will still be able to login and load (since that's not dependent on the Documents folder).
Mklink /H
isn’t allowed with external drives.
Solution 3:
I know this topic is rather old, however, the problem still exists. OneDrive (which seems like a direct ripoff of Dropbox originally, which has the same problem) does not sync symlinked files, if the source folder or file is not within the OneDrive folder. So the easiest solution is, to put the original (source) files into the OneDrive folder and symlink it to whereever else destination you want to edit them. You can edit them in two places and OneDrive will still sync them. Of course, if the destination folder is again synched (e.g. by Dropbox) then that one won't sync it, but that's a rather rare case where you're using OneDrive and Dropbox.
mklink /J "C:\...\OneDrive\SourceFolder" "C:\SomewhereElse\HardlinkedFolderToCreate"
Works for me. I can edit the files from within any of the two folders and OneDrive syncs them fine. I can also edit them online (using OneDrive for Business which syncs into a SharePoint library but that shouldn't matter). Should also work with Dropbox. If you need it the other way around, switch source and destination.