OneDrive and directory junctions sync problems
With Dropbox’s end of Linux support I have been on the search for alternatives, as I will quit my Dropbox contract and need to move considerable data to a different provider. Since I am also a Office365 subscriber I get 1Tb of free OneDrive space, which should be usable. With recent updates of the onedrive package in Debian I am maintaining, using it instead of Dropbox has become a feasible alternative. I also started to use OneDrive extensively on the Windows side to sync my Desktop, documents, and my GPS and Map data (history of 20 years of GPS tracks and loads of maps). Advertised all over the internet (eg here, here, here) is a method to use directory junctions to link arbitrary folders by creating a junction in the OneDrive folder that links to the original folder.
As it turns out, this does not work as expected: Assume the following setup
- There is a folder
- A junction in
and create a file
c:\MyFolder\test.txt. This file is kept in a pending synchronization state and is not properly uploaded to the server.
One can trigger the upload by various methods:
- pause and restart syncing
- change/create any file in
If a sync is triggered by one of the above, also the pending changes in
c:\MyFolder are uploaded, but NOT otherwise.
This did hit me several times because I preferred to have the main folders not in the OneDrive directory, but in their original location. Experimentation turned out that if you do the link source and target switch, so that the actual folder is in the OneDrive directory, and the directory junction wherever you need it, files are correctly synchronized.
For those having the wrong setup already, the following steps allow to switch the direction without triggering a full resync:
- Wait until OneDrive has synced completely, then exit the program from the notification area;
- remove the junction with rmdir, this will not remove the original directory;
- move the original directory into the OneDrive folder;
- recreate the junction with
mklink /j c:\MyFolder %UserProfile%\OneDrive\MyFolder;
- restart OneDrive.
This should bring you back to fully synchronized state in a very short time, and further changes in either the OneDrive folder or the directory junction will immediately trigger a file sync operation.