BackupHelper

Backup of an existing Windows install before disk wipe (WinPE flow). Targets USB stick. Layout: {usbRoot}\NETSetup\Backup\{yyyyMMdd-HHmmss}\Users\ + ...\ProgramData\. Selective ProgramData (chocolatey, ssh, Microsoft\Crypto) — not full tree (most is recreated). Restore counterpart: RestoreHelper.

public static class BackupHelper

1. Fields

1.1. BackupRootSubPath

public const string BackupRootSubPath

2. Methods

2.1. BackupIfFound(ISystemHost, AbsolutePath, AbsolutePath, AbsolutePath?)

Backup C:\Users + selective ProgramData from windowsRoot to backupTarget. Returns false if no Windows install detected.

public static bool BackupIfFound(ISystemHost host, AbsolutePath windowsRoot, AbsolutePath backupTarget, AbsolutePath? scratchDir = null)
Table 1. Parameters
Name Type Description

host

ISystemHost

windowsRoot

AbsolutePath

backupTarget

AbsolutePath

scratchDir

AbsolutePath?

Returns: bool

2.2. BuildBackupTarget(AbsolutePath)

Build a fresh timestamped backup target under {usbRoot}\NETSetup\Backup\.

public static AbsolutePath BuildBackupTarget(AbsolutePath usbRoot)
Table 2. Parameters
Name Type Description

usbRoot

AbsolutePath

Returns: AbsolutePath

2.3. BuildScratchDir(AbsolutePath)

DISM scratch dir on the NETSetup USB: {usbRoot}\NETSetup\scratch. Pre-format use only. WinPE default scratch (X:\Windows\TEMP) too small → DISM error 112.

public static AbsolutePath BuildScratchDir(AbsolutePath usbRoot)
Table 3. Parameters
Name Type Description

usbRoot

AbsolutePath

Returns: AbsolutePath

2.4. DiscoverNetsetupUsbRoot(ISystemHost)

Locate the NETSetup USB by probing for the bootloader marker (\NETSetup\NETSetup.exe). Returns root (e.g. D:\) or null. Used to pick a backup destination. Skips read-only media (CDRom) — backup target must be writable.

public static AbsolutePath? DiscoverNetsetupUsbRoot(ISystemHost host)
Table 4. Parameters
Name Type Description

host

ISystemHost

Returns: AbsolutePath?

2.5. DiscoverWindowsRoot(ISystemHost)

Scan host disks for an existing Windows install. Returns root path (e.g. W:\) or null. Skips WinPE RAM drive (X:) + non-fixed drives (CDRom/Network/Ram).

public static AbsolutePath? DiscoverWindowsRoot(ISystemHost host)
Table 5. Parameters
Name Type Description

host

ISystemHost

Returns: AbsolutePath?