Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On windows 2000 and XP machines I used to be able to do the following:

ntbackup backup systemstate c: /f e:\backups\machineName\machineName-full+systemstate_200101206.bkf

This gave me a full backup of the system that I could use to do a system restore, after doing a barebones OS install. Windows 7 has a great utility for regular backups with alerting and all that stuff. It does not seem to have command line support. I'd like a backup solution for my Windwos 7 systems that has the following features:

  • Is free
  • Is open source (preferebly)
  • Works while the system is booted and leaves the system functional (clonezilla is great for offline backups, and I use that too)
  • 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)
  • Can work via the command line
  • Compression would be nice, the ability to pipe output would be better.
share|improve this question
    
What exactly about the built-in Windows backup doesn't work? It does a full image backup while the machine is running, which you can restore to a completely empty hard drive and have up and running just as it was when you ran the backup. –  nhinkle Mar 10 '11 at 19:21
    
I found the "system image" feature. I just need a command line version of it. –  Justin Dearing Mar 16 '11 at 20:55
    
Ah. Why exactly do you need command line support? –  nhinkle Mar 16 '11 at 22:10
    
I just prefer it that way. Also, if there was command line support, it would be useful for scripting or administrating Windows 2008 servers over ssh. –  Justin Dearing Mar 16 '11 at 22:42
    
Well then, see my answer below. A bit of Googling can do wonders ;) –  nhinkle Mar 16 '11 at 22:54

2 Answers 2

up vote 1 down vote accepted

Windows Backup and Restore can do a full image backup while the machine is running. The images can be restored using the Windows installation disk's repair tools. Backups are compressed, and you can select a local disk or a network share to back up to.

The backup tool can be controlled from the command line using wbadmin.exe. This works both for client operating systems (Windows 7, Windows Vista) and server OSes (Server 2008, Server 2008 R2). The basic commands are as follows:

START BACKUP              -- Runs a one-time backup.
STOP JOB                  -- Stops the currently running backup or recovery
                             operation.
GET VERSIONS              -- List details of backups recoverable from a
                             specified location.
GET ITEMS                 -- Lists items contained in a backup.
GET STATUS                -- Reports the status of the currently running
                             operation.
share|improve this answer

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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:

share|improve this answer
    
That looks promising. –  Justin Dearing Feb 25 '12 at 13:57
    
How do I restore to a currently running system like I do with ntbackup? Do I restore to a shadow cop and do a shadowcopy -r? –  Justin Dearing Feb 25 '12 at 14:35
    
I haven't done it that way. I normally create a new volume, restore to the new volume, and then change the mount points so that Windows considers the new drive with the right drive letter. You could, alternately, create a volume with the same signature as your original and restore it, though I'm not sure how Windows would react to two volumes with the same signature. If you want to restore to the currently running system, I'd envision that, yes, you'd need to use a shadow copy, and then commit the changes from the shadow copy. –  user314104 Feb 26 '12 at 0:21
    
strarc is wonderful. –  naxa Apr 18 '13 at 21:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.