I'm not sure what you mean by this:
Gives me a backup that is suited for a full system restore or partial
system restore (ruling out most imaging software even if they could
work while the system is booted via some sort of shadow copy voodoo)
But I can give pretty much everything else that you requested with VShadow.exe (found in the Windows SDK) and strarc.exe. strarc is open source, though I've never bothered to look for its source.
Here's the recipe:
- Create a shadow copy to get a consistent state. To do this, run
VShadow.exe -p volumename where volumename is the volume you'd like to backup. Examples are C:\, C:\Mounts\D (if this is a mount point for a volume), or \\?\Volume{edbed95e-7e8d-11d8-9d01-505054503030} for a persistent volume name. VShadow will do its thing, but at the end, it'll give you a line with SNAPSHOT ID. Grab the GUID from that.
- Assign a drive letter to the snapshot. Run
VShadow.exe -el=ShadowCopyId,UnusedDriveLetter: where ShadowCopyId is the Snapshot ID you got from the last step. UnusedDriveLetter, of course, is an unused drive letter.
- Perform the backup. Run
strarc -cjd:UnusedDriveLetter:\ 1>MyBackup.strarc 2>MyBackup.err.txt. UnusedDriveLetter should be the same one as in the last step, as this tells strarc where to begin its backup.
- Restore the backup. Run
strarc -xjd:Destination MyBackup.strarc where Destination is self-evident.
strarc doesn't compress its files, so if you want to do that, feed its output to your favorite stream compression program, such as bzip2 or gzip. It's -z option allows you to specify.
One caveat is that Microsoft thinks that VShadow's -p option to expose the snapshot is only available to Server-class operating systems. I found out that this is actually wrong, as I was able to create a drive letter with the -p option on Windows 7 Enterprise. It worked great.
Note that strarc uses the NT backup API (and has support for very long NT path names), but doesn't enable SeBackupPrivilege. This means that you can only backup things that you have access to (and you do, right? You're the Administrator, right?). You could force this with the open-source ProcessHacker; or, since it's open source, you could add an option to enable SeBackupPrivilege. If you do the latter, I encourage you to share. :)
References: