Is Your OneDrive About to Be Permanently Deleted From the Cloud?
By: Louis Waweru
Tags: Storage, Robocopy, Backup, Onedrive, Cloud Storage

For me it was things like…

being an early adopter (+20 GiB) buying a Windows phone (+15 GiB for the Camera Roll, and +200 GiB for buying a phone that no one else would, over and over again. choosing to upload my iPhone pics to the OneDrive Camera Roll after said Windows Phones were sunsetted, much to the sadness of an incredibly loyal userbase (+15 GiB)

Yes, I’m using gibibytes and tebibytes, and you know what else? Right-click > Add to dictionary, folks. I did that. This is about 1024 MBs in a “GB” ladies and gentleman. Not the 1000 MBs in a GB, like hard drive manufactures use to cheat you out of about 6.9% of the storage you thought you were buying, why? Because storage is memory, that’s why!

1024 is 2¹⁰, or a one thousand bytes (1 KiB). 1000 is 10³, or one thousand bits (1 Kb). Storage is saved in units of bytes, so the former is more useful an indicator, while the latter is more useful for making a number seem bigger than it is, and why drive manufacturers use the little b and not big B.

Good While It Lasted

I managed to use 447 GiB out of my allotted 430 GiB. I do see how that should not be possible. At first, I assumed they just liked me, but now I’m leaning towards “it’s a trap!”

Start Copying OneDrive to Local Destination

If You Have Enough Locally Free Storage Space

Then you’re in luck. If it’s not already installed, download OneDrive and click your way through the install accepting the defaults (making sure not to sync your Desktop, Documents and Pictures, if asked).

Once setup, go to Settings’ Settings tab and in the Files On-Demand section, uncheck Save space and download files as you use them. This will cause the OneDrive client to download everything to %UserProfile%\OneDrive , for example C:\Users\Louis\OneDrive . Read more about the option to Save disk space with OneDrive Files On-Demand for Windows 10 if you’d like some more details.

Keep in mind network locations cannot be used as OneDrive locations.

If You Do Not Have Enough Locally Free Storage Space

You’ll be using Robocopy to grab everything from OneDrive to an external or network location.

Robocopy will be aware of the file it has already downloaded, and continue where it left off…

The way this works is OneDrive will grab the requested file and put it in the default OneDrive folder ( %UserProfile%\OneDrive , or C:\Users\Louis\OneDrive in my case). Once there Robocopy will have have a handle on the file and start copying it the remote location.

Eventually you’ll run out of space in the default OneDrive folder and everything will stop. This is fine and expected. We’ll stop Robocopy and OneDrive, delete the OneDrive folder, reset OneDrive and start again.

This will work because Robocopy will be aware of the file it has already downloaded, and continue where it left off, slowly but surely creating an exact copy of your cloud version of OneDrive on your network location.

The following is a walkthrough. In my example my OneDrive folder is located at %UserProfile%\OneDrive which is a pointer to C:\Users\Louis\OneDrive .

My network location is a NAS device mapped to L:\ .

Step 0 - Seed Planting: Do Not Sync Your Local Docs When Asked

Keep in mind that during the install of OneDrive you must not let it handle your current Documents, Desktop and Pictures folders!

If these are the location where all of your data is, then go to the addendum and return here.

Step 1 - Setup OneDrive

You’ll still need to download OneDrive and install it if it’s not already. Accepting the defaults is fine here, and there is no extra step involving the OneDrive settings. Remember Step 0!

Step 2 - Run the Robust File Copy Tool: ROBOCOPY

Open PowerShell or Windows Terminal. Adapt the following command to suit your setup

ROBOCOPY /W:0 /R:0 /E /Z %UserProfile\OneDrive L:\OneDrive

And we’re off, our first Robocopy run.

Step 3 - Free-up Space, Unlink OneDrive, and Kill ROBOCOPY

Once you’ve run out of storage, go to the windows where Robocopy is running and stop it with control + c . Then make sure to unlink OneDrive from the device because now you have to delete everything in the OneDrive folder. Unlinking will ensure nothing is deleted from the cloud.

When erasing everything from the OneDrive folder it may be a good, or safe, idea to not erase the Desktop, Documents, or Pictures folders… just incase you went ahead and decided to sync these to the cloud.

I found myself having to use Task Manager to kill OneDrive during the unlink process, simply because it was taking to long and it didn’t seem to matter much what it was doing after being unlinked (signed out).

Unlink your OneDrive before deleting the OneDrive folder to ensure nothing is deleted from the cloud. By default even if you delete files from your local OneDrive folder they will remain in the cloud, however there is a setting to change this behavior, so unlinking first is a safety measure against data loss.

Step 4 - Relink OneDrive & Re-ROBOCOPY

After freeing up your space, relink OneDrive and start the Robocopy command again. You may be asked if you want to use the same location for OneDrive, say Yes.

Intermediate copy completion.

Repeat from Step 3 until everything has been copied to the network location.

While I was only expecting to do this four of five times, I wound up repeating Step 3 about ten times even though there was about 90 GiB of free storage on my SSD to work with.

Step 5 - Sanity Check!

You’ve done your final Robocopy sync but still feel uneasy. I get it, so did I, just run Robocopy again.

Here are what my final, and final-final runs look like.

Final sync!

Final-final sync! The two directories and one failed copy seem to be related to the innerworkings of OneDrive, and unrelated to my actual content.

I now feel ready to move on without my cloud copies — because I also have backups, as you should!

Step 6 - Reclaim Your Space!

Remove the %UserProfile\OneDrive folder, and the incomplete incremental copy.

The full cloud replica is located on your network drive; L:\ in my case.

My OneDrive cloud content is now on an externally located network drive.

Addendum

If all of your content is in Desktop, Documents, and Pictures, you’ll have to to take care of some prestaging, because we will soon be deleting these locations.

Jump in to a Terminal and back these folders up now:

ROBOCOPY /W:0 /R:0 /E /Z %UserProfile\Desktop L:\OneDrive\Documents

ROBOCOPY /W:0 /R:0 /E /Z %UserProfile\Documents L:\OneDrive\Documents

ROBOCOPY /W:0 /R:0 /E /Z %UserProfile\Pictures L:\OneDrive\Documents

L:\ happens to be the location of my NAS device. Replace this with the letter of your network connection.

Once finished, go back to where we left off.