Windows Backup Utility

OneDrive Backup

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.

Platform
Windows
Run Mode
Non-Admin
Destination
External USB Drive
Copy Engine
Robocopy
OneDrive must be signed in and available. The script is intentionally launched in a normal non-administrator PowerShell session because OneDrive cannot be started from an elevated session.

Workflow

How the backup works

01Find OneDrive
02Choose USB Destination
03Hydrate & Copy
04Restore Online-Only State

OneDrive Detection

Finding the sync folder automatically

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.

Personal and business accounts

The detection logic checks OneDriveConsumer, OneDriveCommercial, the general OneDrive environment variable, and OneDrive account registry entries.

Multiple candidates

If more than one valid OneDrive folder is found, the current script lists the candidates and uses the first resolved path.

Signed-in check

The script verifies account information, the sync folder, and local OneDrive settings before considering OneDrive ready.

Starts OneDrive when needed

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

External-drive selection

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.

USB detection

The preferred path uses the Windows Storage cmdlets to identify disks whose BusType is USB. A WMI-based USB-disk fallback is also included.

Source drive excluded

A destination that uses the same drive letter as the OneDrive source is excluded from automatic selection.

Cloud-style labels ignored

Volumes whose labels begin with Google Drive, OneDrive, Dropbox, iCloud, Box, or SharePoint are ignored by the automatic USB destination scan.

Manual overrides supported

The PowerShell script also accepts an explicit destination path or a destination volume label when run with parameters.

Free-Space Checks

Source and destination safeguards

Before copying, OneDrive Backup calculates the logical size of the transferable OneDrive files and checks available capacity on both the source and destination drives.

5 GB destination buffer

By default, the destination must have enough free space for the calculated OneDrive logical size plus a 5 GB free-space buffer.

5 GB source 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.

Large folders can be split

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.

Items can be skipped

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

Temporary hydration of online-only files

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.

Pin for backup

Online-only files are changed with attrib -u +p so OneDrive downloads their content locally.

Hydration wait

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.

Restore previous state

After the batch copy attempt, temporarily hydrated files are returned to online-only state with attrib +u -p.

Hydration manifest

A JSON manifest records affected paths, batch roots, whether files were pinned, whether they were restored, and timestamps.

This design is intended to avoid permanently converting the user's online-only OneDrive library into an always-local copy just to perform the backup.

Copy Process

Robocopy backup behavior

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.

Folder copies

Directory work items use /E so subdirectories, including empty directories, are included.

Restartable and multithreaded

The current arguments include /Z, /J, and /MT:16.

Limited retry behavior

Robocopy is configured with two retries and a two-second wait between retries using /R:2 /W:2.

Junctions excluded

/XJ is used to avoid following junction points that could cause unexpected recursion.

Backup Output

Timestamped backup folder, log, and manifest

Each normal run creates a new destination folder named with the current date and time, for example:

OneDrive Backup 2026-10-24 12-30-00

robocopy.log

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.

hydration-manifest.json

The manifest records online-only files that were temporarily pinned during the run and whether their original state was restored.

Continues after copy failures

A failed work item is recorded, but the queue continues so other OneDrive items can still be backed up.

Final summary

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

Optional dry-run mode

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

Launching OneDrive Backup

  1. Make sure OneDrive is signed in and that the PC is online.
  2. Connect an external USB drive with enough free space for the backup.
  3. Download and extract OneDrive Backup.zip.
  4. Run Run Me.bat.
  5. The launcher starts PowerShell in normal non-admin mode with -ExecutionPolicy Bypass.
  6. The script detects the OneDrive folder and checks that OneDrive is ready.
  7. An eligible external USB destination is selected automatically unless parameters specify another destination.
  8. Online-only content is hydrated in manageable batches, copied, and restored to online-only state afterward.
  9. Review the final backup path, Robocopy log, and hydration manifest.
  10. Press Enter to close the script.

Transparency

What is intentionally skipped or unchanged

desktop.ini

The script explicitly skips files named desktop.ini.

Selected hidden/system GUID items

Hidden or system items whose names match a GUID-style pattern are excluded by the current skip logic.

No source deletion

The current script copies OneDrive content to another location. It does not delete backed-up source files from OneDrive.

No forced admin elevation

The included launcher deliberately starts PowerShell without -Verb RunAs. This helps preserve normal OneDrive process/account behavior.

FAQ

Frequently asked questions

Does OneDrive Backup require administrator access?

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.

Does it back up online-only files?

Yes, when there is enough temporary source-drive space. Those files are pinned, hydrated, copied, and then restored to online-only state.

How does it choose the external drive?

If no destination is specified, it finds eligible USB volumes and selects the one with the most free space.

Will it fill my C: drive while downloading cloud files?

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.

Does it overwrite one fixed backup folder?

No. Each normal run creates a new timestamped OneDrive Backup yyyy-MM-dd HH-mm-ss folder.

How can I see what failed?

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.

← Back to Downloads