Bacula (Windows)

Disaster Recovery for Windows Server 2012 R2 using Bacula

Disaster recovery for Windows systems has been a hot topic for years. The Bacula manual recommends creating a backup of the system state using "ntbackup" and (after restoring the files) using this backup for restoring the system state. However, ntbackup has not been a part of Windows since Windows Server 2008 and using the new "Windows Server Backup" (also known as "wbadmin") is not a great alternative, because its system-state backups are huge.

Bacula Systems offer a Bare Metal Recovery plugin as part of their Bacula Enterprise solution, however many people (like me) do not want to migrate to a commercial solution for their whole backup system.

Therefore I wondered, whether there might be a better solution for having disaster recovery with Bacula. My idea was that, using VSS, Bacula itself should be capable of creating an accurate backup of the system state and the main problem is not backup but restore. For my tests, I created a virtual machine running Windows Server 2012 R2 and set it up as an Active Directory domain controller. I used this setup because disaster recovery of a domain controller was one of my main points of worry. The idea is that, if you can restore a domain controller, all other things will be simple in comparison. I made a backup of the whole C: drive of this virtual machine using Bacula (having VSS enabled). Then I shutdown the virtual machine, created a new virtual machine with the same configuration and tried to restore the backup. This mimics the situation that I completely lost a system and now have to restore it on a new computer having the same hardware components. In my case having the same hardware is a pretty good assumption, because I like to run Windows Servers in VMs anyway.

The following guide lists the steps that I used for restoring the system. Although I tested it with Windows Server 2012 R2, I think the same steps will apply for disaster recovery of a Windows Server 2008, Windows Server 2008 R2 or Windows Server 2012 system.

Important Note: The steps described here worked for me in a particular situation. For example I restored from a full backup (without any differential or incremental backups in between). If you want to use differential or incremental backups, I think that at least you will want to enable the Accurate option on the job. For a different system configuration, these steps might not work. So you should not rely on the steps described here for disaster recovery, but instead test whether these steps work for your situation. It is much more comfortable to test a restore when you know that the original system is fine than when the restore just has to work. I can sleep better at night when i know that I tested restore procedures for critical systems.

Step-by-Step Guide

  1. We have to build a Windows 7 x64 image using WinBuilder / multiPE (x86 might also work). The German computer magazine PC-Welt provides a nice download bundle that contains everything needed (apart from the Windows system itself of course). It is important to include the Visual C++ runtime (with 32-bit compatibility support). This option named "Force x86 SideBySide For 64-Bit Operation Systems" can be found in WinBuilder under "VC++ 2008". A PE-disk based on Windows XP might not work, because Windows XP did not support Junction Points (although the support for them has been in NTFS for decades), so Bacula might not be able to restore them. If we have a NIC or disk controller that is not natively supported by Windows, we have to include the corresponding drivers in the PE disk because otherwise we will not be able to restore the backup later.

  2. First we have to boot from the operating-system installation-disk and install the OS the same way we would for a new system. However, to save some time, we can use the "Server Core" installation because we only do this to create partitions and to restore the boot loader. We stop the installation process at the time of the first reboot.
  3. Now we boot from the PE-disk created with WinBuilder. We assign the C: drive letter to the new system partition on the hard-disk (using Disk Management), so that Bacula will restore the files to the right partition.

  4. We format the C: drive, so that the files that were just created by the installer are deleted.
  5. Now we have to download and install the Bacula File Daemon. It makes sense to use the same version of the Bacula FD that was used to create the Backup. For a 64-bit PE-disk we use the 64-bit version of Bacula. We use an installation path that for sure does not exist in the image to be restored (e.g. C:\BaculaJustForRestore). If we used the default path, we would get a collission with the Bacula files that are part of the restore. We remove the checkmarks on the "Install as service" and "Start after install" options because we will take care of starting Bacula manually once we have adjusted the configuration.

  6. After the installation has finished, we open the bacula-fd.conf file and make sure that the configuration is correct: Basically, we want the same settings here that we had on the original system. In particular, the client name, director name and password should match. We also have to make sure that the paths for the working and PID directories point to the correct (non-standard) directory.

  7. Finally, we have to ensure that the IP address of the system is set correctly. If the IP address does not match the address in the Bacula director configuration, we can either change the director configuration or manually configure the IP address of the system.
  8. Now we start the Bacula FD by opening a command prompt, changing to the installation directory and running bacula-fd.exe with the right command-line parameters. Example:

       1 c:
       2 cd BaculaJustForRestore
       3 bacula-fd /run -c C:\BaculaJustForRestore\bacula-fd.conf
  9. Now we are ready to start the restore in the Bacula console. We have to select the whole C: drive (but no other drives - we can restore them later). In the restore options we set an empty prefix ("/") for the target location ("Where:"), so that the files are restored to their original location on the C: drive.
  10. When the restore has completed, we shut the computer down and remove the PE-disk. That’s it. The next time we boot the computer the restored system should boot. After that, we can delete the temporary Bacula installation and restore the files on other disks (if there are any).

If the computer does not boot the system in step 10, the first thing I would try would be to boot from OS installation disk and use startrep.exe in repair mode. However, this is not a part of this guide, because for me it worked right away.

Making a system state backup using Windows Server Backup

If you want to make a system state backup using Windows Server Backup each time that you make a backup with Bacula, you might find the following script useful, that you can add as a run before job script.

   1 @echo off
   2 if "%1" == "" (
   3   echo Backup job level has to be passed as first parameter.
   4   exit /b 1
   5 )
   6 if /i %1 == full (
   7 rem  wbadmin delete systemstatebackup -backupTarget:p: -keepVersions:0 -quiet
   8   if exist p:\WindowsImageBackup rd /s /q p:\WindowsImageBackup
   9   wbadmin start systemstatebackup -backupTarget:p: -quiet
  10 ) else (
  11   echo Backup Level is %1, skipping system state backup.
  12 )

This script will delete all existing backups in the target location (P:) and create a new system-state backup. However, it will only do this when Bacula makes a full backup (to save space). You will probably have to adapt this script to your needs.

CategoryEnglish CategoryWindows

Windows/Bacula (last edited 2018-01-11 13:04:07 by SebastianMarsching)