Thursday, February 6, 2014

System State and Bare Metal backups from the command line (Server 2012)

The baremetal backup system on Windows server 2008 R2 and all flavors of Windows 2012 is pretty awesome and pretty much does away with the need for Ghost and similar products.

One snag, in my opinion, is the Wizard that can be used to create scheduled backups. It will not allow you to schedule backs less aggressively than daily. The answer, as always is in the command prompt.

The command line tool is wbadmin and, as is typical with my blog, I am not going to re-publish all the various options and functions associated with this tool. Instead I refer you to:

http://technet.microsoft.com/en-us/library/cc754015.aspx

However, here is the syntax you need to do a baremetal backup:

wbadmin start backup -allcritical -systemstate -backuptarget:Q: -vssfull

Now let's examine this a little:
  • Strictly speaking you do not need to specify -systemstate for a baremetal backup, it is included (implied) in the -allcritical switch. The purpose of specifying -systemstate is to give you the additional option of doing a system-state restore without performing a complete baremetal restore.
  • Q: is just my example, use your own drive letter!
  • The -vssfull switch is generally not needed, it makes no difference to what is backed up, but if you have a product such as Exchange installed and you have a 3rd party backup agent that is used to commit transaction logs as part of a backup, that product may break with -vssfull.
Now, if you want to schedule this, then we can create a scheduled task like this:

SCHTASKS /Create /SC WEEKLY /D SAT /TN WeeklySystemStateBackup /RL HIGHEST /
ST 19:00  /TR "WBADMIN START SYSTEMSTATEBACKUP -allcritical -systemstate -backup
Target:q: -quiet -vssfull"

Some notes on this:
  • /Create = Create a new scheduled task.
  • /SC = Schedule, this will accept tokens like MINUTE, HOURLY, DAILY, WEEKLY etc.
  • /D = Days e.g SAT for Saturday
  • /RL = Run Level
  • /ST = StartTime in our case 19:00
  • /TR = Task to Run which as you can see from the example, is the executible and all switches
For a full lesson on 'SCHTASKS' see


Interestingly, the schedule backups created by this task will show up in the Windows Backup GUI and the GUI will know how to offer you the various recovery options from these backups, It will even show you a live progress status while your backup is running. However, the GUI will continue to complain that you have no backup schedule because it did not create your scheduled task. I haven't figured that one out yet.

Now one nice option in the GUI is to use a 'dedicated disk'. All this really does is convert the target to GUID form and remove the drive letter from the disk. You can do that if you wish - here's how:


  • Find the GUID of the disk you want to use as the target. The easiest way is using MountVol on the command line with no parameters. This will produce a list of all your drives and their GUID. In my example it shows thus:
\\?\Volume{a5c902a5-9bc8-4aa1-8b48-59f9c3e45a4a}\
Q:

The piece I want to extract is basically all of it without the drive letter, so:

\\?\Volume{a5c902a5-9bc8-4aa1-8b48-59f9c3e45a4a}

  • Next - prove you have the right one by pasting this into START-RUN it should open an explorer window and you should see what you expect.
  • Next - modify the scheduled task by inserting the string after the TARGET: and remove the old drive letter from the syntax, so in my example, this: 

WBADMIN START SYSTEMSTATEBACKUP -allcritical -systemstate -backup
Target:q: -quiet -vssfull


becomes:


WBADMIN START SYSTEMSTATEBACKUP -allcritical -systemstate -backup
Target:\\?\Volume{a5c902a5-9bc8-4aa1-8b48-59f9c3e45a4a} -quiet -vssfull

Then use disk manager to remove the drive letter. Don't forget to test your new configuration.

Cheers!

1 comment:

  1. Nice writeup. I like your use of " -systemstate" to offer the option of a systemstate restore, instead of only a full Bare Metal restore.

    ReplyDelete