Introduction
Zeta Backup Validator (ZBV) is a small .NET 3.5 console application that helps you in verifying whether your backups succeed by checking files and folders with various configurable rules (folder size, file age, etc.).
Overview
We developed ZBV to enable us to verify the successful creation of backups from various sources in a more reliable and automated way.
We fetch daily backups from our web servers, from local PCs, from servers in the LAN, from databases, you name it. Usually, we took some minutes/hours in the morning, looked at the folders and the files and decided whether the backups ran successfully.
To save us time, we developed ZBV that saves us from looking at the files. What ZBV does is look at folders and files and check them against several configurable rules. If a rule fails, the administrators will get an error e-mail message, if all rules succeed, the administrator will get a success notification e-mail message.
Features
ZBV allows for automated checking of folders and files to previously defined rules. When a rule results in success or in failure, an e-mail message is generated. The subject and content of the e-mail message can be configured, by yourself.
The rules are defined in an easy-to-understand configuration file. Currently the following rules are available:
- Checking for maximum age of files in a folder
- Checking for maximum age of a single file
- Checking for the minimum size of all files in a folder
- Checking for the minimum size of a single file
Current State of the Tool
Although we are using ZBV on a daily basis, there is still room for improvements:
- Add more rules
- Add rules for content inspection, e.g. reading file content and parsing the content
- Send notification to other sources than just e-mail
- Your suggestions here
Usage
Creating Scheduled tasks
Usually you configure one or multiple scheduled tasks in the Windows Task Scheduler that fired one or multiple calls to ZBV.
E.g. you can configure a scheduled task to run on a daily basis to check your backup files. Be sure to execute the scheduled tasks after your backups are performed.
Calling Syntax
To actually call ZBV, call the "zbv.exe" application.
The rules configuration file to process can be passed to "zbv.exe" either by specifying it in the application configuration file "zbc.exe.config" in the "appSettings
" section with the key "configurationFilePath
" or by passing the configuration file as the first command line argument in the command line. In both modes, you can use path placeholders.
So a valid command line would look like:
"c:\program files\zbv\zbv.exe" "$(SpecialFolder.ExecutingAssembly)\my-server.xml"
The placeholder "$(SpecialFolder.ExecutingAssembly)
" in the example would be expanded to the folder path of the executable, i.e. "c:\program files\zbv\zbv.exe".
Configuration
This chapter explains which elements you have to configure before you can use ZBV successfully. Although the chapter outlines several important items to configure, it does not go into every detail.
The best way to learn is to first read the manual and then take a look at the example files.
Application Configuration File "zbv.exe.config"
The application configuration file exists once. Open it with any (XML) text editor (e.g. Notepad or another text editor like "Notepad++" - but not with e.g. Wordpad or Microsoft Office Word, since the content will be rendered unusable).
Please examine the shipped application configuration file for details.
"appSettings" Section
Specify the mail sender and receivers and the e-mail subject as well as the templates to use in the "appSettings
" section.
See the "appSettings" documentation for a complete syntax on how to use it.
"log4net" Section
Specify how and whether to log low level events. The defaults are to log to a text file (change the path to fit your requirements) and to the console window.
See the log4net website for a complete documentation on how to configure logging.
"mailSettings" Section
In order to successfully send out e-mail messages, ZBV needs to know the SMTP server to use. Specify all SMTP related settings, including authentication settings, in the "mailSettings
" section.
See the "mailSettings" documentation for a complete syntax on how to use it.
Rules XML File
You can create any number of XML configuration files. The download of ZBV ships with an example configuration file "zbv-config.xml" that you can open with any (XML) text editor (e.g. Notepad or another text editor like "Notepad++" - but not with e.g. Wordpad or Microsoft Office Word, since the content will be rendered unusable).
Typically you define one configuration file per server to check.
An excerpt from a configuration file looks like the following:
<ValidationDirectory Name="Exchange Server" Path="\\my-server\Backup\Exchange">
<ValidationMethods>
<ValidationMethod Type="MaxAge" Domain="SingleFile"
DomainName="ExchangeBackup.bkf" Value="24"
SignificanceLevel="ErrorLevel" />
<ValidationMethod Type="MinSize" Domain="SingleFile"
DomainName="ExchangeBackup.bkf" Value="10000000000"
SignificanceLevel="WarningLevel" />
</ValidationMethods>
</ValidationDirectory>
You can enter multiple "ValidationDirectory
" nodes per configuration file. Each node contains one or multiple validation methods (i.e. the "rules") to execute.
The following attributes exist:
Type
MaxAge
- Checking the age of the oldest file in a folder or the age of a directly specified file.
MinSize
- Checking the size of a file or a folder.
Domain
Directory
- If type is "MaxAge
" the specified folder and all child folders are being checked for the oldest file. If type is "MinSize
" the size of the folder (i.e. the sum of the sizes of all contained files) is checked.
NewestFile
- The newest file in a specified folder and all child folders.
OldestFile
- If type is "MaxAge
", this option checks for the oldest file in the specified folder. If type is "MinSize
" the oldest file in the folder is checked for its size.
SingleFile
- A single file. The file name is entered in the "DomainName
" attribute.
FileGroup
- A wildcard for a group of files like e.g. "*.txt". The wildcard itself is entered in the "DomainName
" attribute.
Value
MaxAge
- The number of hours that specifies the maximum allowed age of a file or the oldest file in a folder.
MinSize
- The minimum file size in bytes.
SignificanceLevel
Here you specify how to treat rule failures.
WarningLevel
- Report failure as warning.
ErrorLevel
- Report failure as error.
E-mail Template Files
For all rules in one rule XML file, one single e-mail message is generated and sent out. By using e-mail template files, you can configure the layout and format of the generated e-mail messages.
The templates must be specified in the application configuration file to point to the correct files (see above).
The following template files exist:
- "template-summary.html" - The main envelope of a generated e-mail message.
- "template-fragment-error.html" - A HTML fragment for notifying about a rule that filed with an error.
- "template-fragment-warning.html" - A HTML fragment for notifying about a rule that filed with a warning.
Each HTML file contains various placeholders that will be expanded upon actual sending of a notification e-mail message. You can edit the HTML files with any (HTML) text editor like e.g. Notepad, Microsoft Expression Web or Adobe Dreamweaver.
A template fragment is being used for each error or warning that occurs during a rule check. The fragment is inserted one or multiple times into the main envelope HTML e-mail message before sending.
Troubleshooting
If you have errors during installation or configuration, check the following items:
- Inspect the Windows Event Log for detailed error messages.
- Inspect the log files that the ZBV executable writes to.
- See the console window output of ZBV.
- Use the comments section below on this page and ask for further assistance.
Epilog
In this article, I've introduced a small application to enhance the quality of your backups by helping you check the backups for certain rules.
When voting, please notice that I put my article in the "Utilities" section, so I assume it is safe to not post any source code explanations in the article itself. Thanks.
History
- 2009-11-16 First release on CodeProject.com