The OneDrive client has come a long way but it is still a common frustration for it to get stuck, especially when working with large file sets. The process below can be used completely reset the OneDrive back to a working state without losing any unsynchronised changes.
OneDrive is legitimately stuck
Often the OneDrive app is stuck for good reason – because a file is locked out that it’s trying to sync or because it’s currently working through a large changeset that is taking time to process.
The OneDrive activity log will lie to you and doesn’t give an accurate picture of what’s going on – especially where OneDrive is talking to SharePoint or auditing the local files on your device. Just because the log hasn’t changed in a while or your CPU activity is low doesn’t necessarily mean it’s not doing anything.
A reboot can often fix the former issue (sometimes it’s a service like the search indexer or a virus scanner locking files out) and the latter can be solved with a bit of patience. Leave it synchronising overnight or over a weekend if you can (just make sure sleep is turned off and chargers etc. are left plugged in).
Pause / Resume Trick
One trick which sometimes helps is to pause the OneDrive sync (from the settings cog) and then immediately resume it again once the pause has gone through (be patient).
It can take many repeated attempts of pause/resume for this to work (I have no idea what is going on behind the scenes) but I have known this technique to clear some stubborn synchronisation issues. You can usually tell if it’s working because each time you do it, the activity log will show a bit of a change e.g. a single file being uploaded or deleted.
Free up Space
Another trick is to use the “Free up space” option on the Windows right-click menu to force any local data up into the cloud. Right click on the top-level folder in your OneDrive (and/or synchronised libraries) and choose “Free up Space”.
This can take a long time to process so be patient and wait for it to finish everything it’s doing. It will either clear the issue or you will eventually go back into a familiar holding pattern where it gets stuck again).
Even if this doesn’t clear the synchronisation issue, sometimes it can help to narrow down which file/s are locking up the job. You can try manually dragging these out of your sync folder to see if it clears the problem.
Sync issues are occasionally a result of disk or file system corruption. Running chkdsk /f C:\ (replacing C with the drive letter of your OneDrive) from the command line can sometimes cure the issue. You’ll need to reboot after running the command to trigger the scan.
Reset OneDrive (the Microsoft way)
Finally you can follow the steps here to reset the OneDrive client using the official Microsoft way:
I’ve personally had mixed success with this method and despite what the page says, I have known this method to lose unsaved changes on occasion – if not at first then later on when you sign back into OneDrive and restart the sync.
Be careful and avoid this method where any loss of data would be a big problem (for example where the folders are weeks or months out of sync).
When all else fails, the following method can be used to safely get OneDrive back to a working state:
Step One – Create backup folders
Create a folder on the PC outside of OneDrive to backup your changed files. Create a sub folder for each OneDrive folder and/or SharePoint location being synchronised. The root of C:\ drive can be a good location for this. Be mindful if you have OneDrive backup enabled as this can move certain folders into the sync that you might not expect like Desktop and My Documents.
For example an average corporate deployment might have the following 3 sub folders:
C:\ODBackups\OneDrive – Personal
C:\ODBackups\OneDrive – My Company
C:\ODBackups\My Company – SharePoint Name
Step Two – Free up space
Use the Free up Space method from the previous section to remove as many local files from the device as you can. Let this fully complete, leaving it to sync overnight or over a weekend if you need to (it can take a very long time for big file sets).
Step Three – Backup files which haven’t synchronised
Restart the PC and ensure OneDrive is stopped (double check in Task Manager to make sure the app is fully shutdown).
From an elevated command prompt, run the following commands substituting <source path> for your OneDrive folder and <backup path> for the backup folder. Repeat all three commands for all of your OneDrive folders and SharePoint sync folders:
> robocopy /xa:O /e /XJ /MT /R:0 /W:0 "<source path>" "<backup path>" > cd “<backup path>” > for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do rd "%d"
The first command copies all files from your sync folder into your backups folder excluding those that have the “Offline” attribute set (i.e. cloud stubs). This method is not perfect because Microsoft now use a bunch of new and improved file attributes to identify cloud stubs but without scripting something in C++ it is impossible to read the new attributes and from my testing this method seemed good enough to get the job done.
The second and third commands (starting “cd” and “for” respectively) are used to remove empty folders from the backup location. These are optional but help to provide a clearer picture of exactly what’s been copied, for example if you needed to verify the backup set with the end user to confirm that certain documents are present.
Step Four – Completely remove OneDrive and reinstall
Step Five – Restore files from backup
Once the OneDrive has resynchronised all of your libraries, the final step is to copy back the files from your backup location to their respective sync folders. You can drag/drop these using Windows Explorer here and use the “overwrite changes” option.
Once OneDrive finishes synchronising your changes, you are good to go!