Personal and business accounts
The detection logic checks OneDriveConsumer, OneDriveCommercial, the general OneDrive environment variable, and OneDrive account registry entries.
Windows Backup Utility
OneDrive Backup is a free PowerShell utility designed to copy the contents of a local OneDrive sync folder to an external drive while safely handling Files On-Demand content. Online-only files are temporarily hydrated when needed, copied with Robocopy, and then returned to their previous online-only state.
Workflow
OneDrive Detection
Unless a source path is provided manually, the script checks OneDrive environment variables and current-user OneDrive registry account data for valid sync-folder paths.
The detection logic checks OneDriveConsumer, OneDriveCommercial, the general OneDrive environment variable, and OneDrive account registry entries.
If more than one valid OneDrive folder is found, the current script lists the candidates and uses the first resolved path.
The script verifies account information, the sync folder, and local OneDrive settings before considering OneDrive ready.
If OneDrive is signed in but not running, the non-admin script tries to locate OneDrive.exe, start it, and wait briefly for the process to become available.
Destination
When no explicit destination path or volume label is supplied, the script searches for USB-attached storage volumes and automatically selects the eligible destination with the most free space.
The preferred path uses the Windows Storage cmdlets to identify disks whose BusType is USB. A WMI-based USB-disk fallback is also included.
A destination that uses the same drive letter as the OneDrive source is excluded from automatic selection.
Volumes whose labels begin with Google Drive, OneDrive, Dropbox, iCloud, Box, or SharePoint are ignored by the automatic USB destination scan.
The PowerShell script also accepts an explicit destination path or a destination volume label when run with parameters.
Free-Space Checks
Before copying, OneDrive Backup calculates the logical size of the transferable OneDrive files and checks available capacity on both the source and destination drives.
By default, the destination must have enough free space for the calculated OneDrive logical size plus a 5 GB free-space buffer.
When online-only files need to be hydrated, the script also preserves a default 5 GB source-drive buffer beyond the temporary space required for that batch.
If an entire directory would require too much temporary local space to hydrate at once, the script can enqueue its child items and process them in smaller batches.
If even the smaller work item cannot be hydrated without violating the source free-space buffer, the script warns and skips that item rather than filling the drive.
Files On-Demand
OneDrive Backup examines OneDrive file attributes to distinguish Always Available, Online Only, and locally available content. Online-only files needed for a backup batch are temporarily pinned with Windows attrib, then the script waits until they can be read.
Online-only files are changed with attrib -u +p so OneDrive downloads their content locally.
The script checks every five seconds until the files are no longer online-only and can be opened for reading. The default hydration timeout is 90 minutes.
After the batch copy attempt, temporarily hydrated files are returned to online-only state with attrib +u -p.
A JSON manifest records affected paths, batch roots, whether files were pinned, whether they were restored, and timestamps.
Copy Process
OneDrive Backup uses Windows Robocopy to preserve the OneDrive folder structure on the external drive. The copy uses restartable mode, unbuffered I/O, file and directory timestamps/attributes, junction exclusion, limited retries, and multithreaded copying.
Directory work items use /E so subdirectories, including empty directories, are included.
The current arguments include /Z, /J, and /MT:16.
Robocopy is configured with two retries and a two-second wait between retries using /R:2 /W:2.
/XJ is used to avoid following junction points that could cause unexpected recursion.
Backup Output
Each normal run creates a new destination folder named with the current date and time, for example:
Robocopy output is appended to a log file inside the backup folder. Copy failures with Robocopy exit codes 8 or higher are recorded and surfaced as warnings.
The manifest records online-only files that were temporarily pinned during the run and whether their original state was restored.
A failed work item is recorded, but the queue continues so other OneDrive items can still be backed up.
At completion, the script reports whether the backup completed cleanly or with warnings and displays the backup root, log-file path, and manifest path.
WhatIf
The PowerShell script supports a -WhatIf switch. In that mode it reports the intended destination and Robocopy commands without creating the backup folder, changing Files On-Demand state, saving the manifest, or copying files.
How To Run
Transparency
The script explicitly skips files named desktop.ini.
Hidden or system items whose names match a GUID-style pattern are excluded by the current skip logic.
The current script copies OneDrive content to another location. It does not delete backed-up source files from OneDrive.
The included launcher deliberately starts PowerShell without -Verb RunAs. This helps preserve normal OneDrive process/account behavior.
FAQ
No. The included Run Me.bat intentionally starts it in non-admin mode, and the script warns that OneDrive cannot be started from an elevated session.
Yes, when there is enough temporary source-drive space. Those files are pinned, hydrated, copied, and then restored to online-only state.
If no destination is specified, it finds eligible USB volumes and selects the one with the most free space.
The script checks temporary hydration requirements and keeps a default 5 GB source-drive buffer. Oversized folders can be split into smaller batches, and items can be skipped when there still is not enough space.
No. Each normal run creates a new timestamped OneDrive Backup yyyy-MM-dd HH-mm-ss folder.
Robocopy output is saved in robocopy.log, failed work items are summarized at the end, and the hydration manifest records the temporary Files On-Demand state changes.