ntbackup workalike for adhoc full backups in Windows 7 thats free and preferably open source
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.
Solution 1:
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.
Solution 2:
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
wherevolumename
is the volume you'd like to backup. Examples areC:\
,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 withSNAPSHOT ID
. Grab the GUID from that. - Assign a drive letter to the snapshot. Run
VShadow.exe -el=ShadowCopyId,UnusedDriveLetter:
whereShadowCopyId
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
whereDestination
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:
- http://msdn.microsoft.com/en-us/library/windows/desktop/bb530725%28v=vs.85%29.aspx
- http://www.ltr-data.se/files/strarc.txt