Backing up Exchange Server with Bareos

1,200 views
Skip to first unread message

Felix Zachlod

unread,
Jun 13, 2014, 9:01:47 AM6/13/14
to bareos...@googlegroups.com
Hello!

we where very unhappy with having Bareos to backup our whole Exchange DB each and every day. Furthermore Exchange is not able to recognize the backup taken by Bareos as full backup and will never flush the log files. This situation is very unsatisfactory. So I read a bit about VSS snapshotting and was finally able to set up a nearly perfect solution with the use of some scripting on the client.

Here is what you will need (We assume the Exchange Database is in one Folder named ExchangeDB and the transaction log in the ExchangeLOG folder on the same (virtual) drive:

FileSet {
Name = "ExchangeFullDB"
Ignore FileSet Changes = yes
Enable VSS = no
Include {
Options { signature = MD5
}
ExcludeDirContaining = nobackup.txt
File = "B:/ExchangeDB"
File = "B:/ExchangeLOG"
}
}

Notice that B: ist NOT the actual drive where the exchange db resides but a temporary drive letter where we will expose the VSS snapshot. Furthermore notice that Enable VSS is set to no as our client script will take care of taking a vss snapshot. The ExcludeDirContaining directive is important this will make us able to exclude the DB from all incremental (and differential) backups.

Here is the Jobdef.

JobDefs {
Name = "ExchangeServer"
FileSet = ExchangeFullDB
Type = Backup
Level = Incremental
Messages = Standard
Pool = Default
Full Backup Pool = HDDFull
Incremental Backup Pool = HDDIncr
Differential Backup Pool = HDDDiff
Priority = 10
Schedule = MonthlyCycle2
Write Bootstrap = "/var/lib/bacula/%c_%n.bsr"
Allow Duplicate Jobs = no
Prefer Mounted Volumes = no
Client Run Before Job = "C:/Programme/Bareos/Scripts/pre_backup_ex.cmd %l"
Client Run After Job = "C:/Programme/Bareos/Scripts/post_backup_ex.cmd"
Reschedule On Error = yes
Reschedule Interval = 1 hour
Reschedule Times = 20
}

And here is the pre_backup_ex.cmd which will reside on the client:

@echo off
if "%1" == "" (
echo Backup job level has to be passed as first parameter.
exit /b 1
)
if /i %1 == full (
IF EXIST E:\ExchangeDB\nobackup.txt del /F E:\ExchangeDB\nobackup.txt
diskshadow -s "c:\Program Files\Bareos\Scripts\pre_backup_ex_diskshadow.txt"
) else (
copy /y nul E:\ExchangeDB\nobackup.txt
diskshadow -s "c:\Program Files\Bareos\Scripts\pre_backup_ex_diskshadow_nofull.txt"
)

Furthermore this is the post backup script:

@echo off
diskshadow -s "c:\Program Files\Bareos\Scripts\post_backup_ex_diskshadow.txt"

pre_backup_diskshadow.txt:

#DiskShadow script file
delete shadows all
set context persistent
begin backup
add volume E: alias ExVolumeShadow
create
expose %ExVolumeShadow% b:
end backup

pre_backup_diskshadow_nofull.txt

#DiskShadow script file
delete shadows all
set context persistent
begin backup
add volume E: alias ExVolumeShadow
create
expose %ExVolumeShadow% b:

Note that the only difference is we are not issuing and end backup command here. That cancels the VSS operation and Exchange does not flush logs.

This produces an error message in the Eventlog which can be ignored but I don't know of a better solution right now.

A drawback is that end backup in case of a full backup will be issued BEFERE the actual data is flowing from the snapshot to the backup medium. I currently don't know a sultion for this cause of the design of Bareos pre/post scripts and disshadow. One can call a script from within diskshadow to do the backup but that does not help us. I don't see a possibility to quit diskshadow without destroying the context thats why I need to call end backup in the pre script else Exchange will not flush logs. You COULD instead run all the client stuff asynchronous and copy the Exchange Data somewhere manually where you grad it later with Bareos but this seemed to complicated for me. Instead I installed a job repition in case of a failing backup- which is not 1000% safe but seems good enough to me.

The last one is the rather boring post_backup_ex_diskshatow.txt:

#DiskShadow script file
delete shadows all

Which should in case of a successful backup delete the shadow copy. Possibly one could modify the pre script to not remove the shadow that would lead in case of a failure of a persisting b drive which can be copied the next time the backup runs. But this all is up to you.

I hope this helps other users too.

regards, Felix

Andrew Wippler

unread,
Oct 1, 2014, 7:44:07 PM10/1/14
to bareos...@googlegroups.com
Hi Felix,

I am looking at BareOS to do our exchange backups as well. Have you changed your script after posting this? Is it still running as expected after all these months?

Reply all
Reply to author
Forward
0 new messages