It’s not uncommon to want to keep an eye on a specific file. In this case, I want to make sure my backups are running on multiple servers. Here is how I setup fairly simple set of scripts to monitor the files and email the results.
After setting up the backup procedure, I proceeded to build the monitor that will check the backups and then email the results.
bmail.exe is the program that allows me to email from a command line in Windows and will need to be placed in the same folder as the .bat files.
GetBackupInfo.bat is what creates the file which will be emailed.
del C:\pstools\backupcheck.txt echo. >>"C:\pstools\backupcheck.txt" echo ~~~~~ Daily Backup Check ~~~~~~ >>"C:\pstools\backupcheck.txt" echo. >>"C:\pstools\backupcheck.txt" echo. >>"C:\pstools\backupcheck.txt" echo ----- Computer1 ----- >>"C:\pstools\backupcheck.txt" dir /s \\Computer1\E$ |find "backup1" >>"C:\pstools\backupcheck.txt" echo. >>"C:\pstools\backupcheck.txt" echo. >>"C:\pstools\backupcheck.txt" echo ----- Computer2 ----- >>"C:\pstools\backupcheck.txt" dir /s \\Computer2\c$\backup |find "backup1" >>"C:\pstools\backupcheck.txt" echo. >>"C:\pstools\backupcheck.txt" echo. >>"C:\pstools\backupcheck.txt" echo ----- Computer3 ----- >>"C:\pstools\backupcheck.txt" dir /s \\Computer3\c$\backup |find "backup1" >>"C:\pstools\backupcheck.txt"
Now that we have created the text file that is getting emailed out, it’s time to create the send_email.bat is what actually calls bmail.exe and sends the email.
bmail -s mailserver.domain.com -t email@torecieve.com -f BackupNotice@domain.com -h -a "Monitored POS Backups" -m backupcheck.txt -d-h -a "Daily Backup Check" -m backupcheck.txt -d
To pull everything together there is a Windows Scheduled task which runs SendResults.bat
call GetBackupInfo.bat call send_email.bat
That’s it, you may need to adjust a few things, such as the filter if you want to find other text strings but this should help get you started.