Scripting Help?

Started by Jeff Zylstra, December 20, 2012, 02:19:25 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Jeff Zylstra

I use Acronis backup on my file server to do daily backups.  It backs up to a connected IOSafe hard drive, and then copies that back up file to a USB hard drive that we take off premises every night.  The problem that I have is that periodically, some of the USB hard drives that I use will get assigned different hard drive letters.  Since the backup routine copies the backup file to a proscribed hard drive letter, when the USB hard drive is assigned a different drive letter, the copy procedure fails.

I have installed a utility that allows me to set the drive letter of the USB hard drive.  But since I am a skeptic, I want to run a test at a certain time each weekday, to see if that hard drive letter is accessible on the server.  I would probably use Windows own Task Scheduler to run it at a prescribed time.  I'm wondering if a batch command or VBS script could be used for this, and if a pass or fail message could be Emailed to me. 

I know that Task Scheduler can send Emails, but I don't know if a batch file could pass a result code on via an Email.  Hopefully this makes sense to someone who knows what they're talking about.  ;)  Thanks in advance.
"We hang the petty thieves, and appoint the great ones to public office"  -  Aesop

Bloody Jack Kidd

Sysadmin - Parallel42

Jeff Zylstra

Quote from: Bloody Jack Kidd on December 20, 2012, 02:20:21 PM
How is that IOSafe drive?

I actually like it a lot.  I don't know if it's fast or slow, since I haven't had to restore from it, but it installed without a hitch and hasn't given me a moment's worth of grief so I'm happy with it.
"We hang the petty thieves, and appoint the great ones to public office"  -  Aesop

Gene Foraker

I have the IOSafe drive and it has worked like a champ.   I just use the Microsoft server backup software to back up to it because I use the other software to do a tape backup each night.

Anything wrong with the Microsoft SBS 2003 software?
Gene Foraker CPCU
Gates-Foraker Insurance Agency
Norton, OH


My posts are a natural hand made product. The slight variations in spelling and grammar enhance its individual character and beauty and in no way are to be considered flaws or defects.

Mark

I think I can whip something up for you as soon as I get to the office this morning.   Gotta drive the first grader to school today.
Mark Piontek, MBA
Director of Information Systems
BS in Information Systems Security

Jeff Zylstra

Quote from: Mark on December 21, 2012, 08:24:15 AM
I think I can whip something up for you as soon as I get to the office this morning.   Gotta drive the first grader to school today.

Thanks, Mark.  And it's pretty cool that you're driving your son to school.   I just drove my grandson to high school this morning.  Treasure those moments.  They pass much more quickly than you realize, and now is when your kids will listen to what you're saying.  It's too late in high school.  Well maybe not, but they'll give you absolutely no satisfaction that they're listening.  ;)
"We hang the petty thieves, and appoint the great ones to public office"  -  Aesop

Mark

Listen??  Besides the fact that my kid talks so much he doesn't give me a chance to speak, I don't think he's paying any attention when I talk to him. lol

Off to scripting land.  This will probably be basic, but should get the job done for you.  Be back shortly.
Mark Piontek, MBA
Director of Information Systems
BS in Information Systems Security

Mark

OK, here's what I did, nice and simple!

First, create a blank file on each USB drive named check.file.  It can be blank or whatever, it doesn't matter.

Then, take this text and save it as a .bat file to the C drive on the server.  Make sure to change X:\ to whatever drive letter you assign to the USB drives.

@echo off
REM Look for check.file.  If not exist, send email

If exist X:\check.file goto end
Call C:\SendMail.vbs

:end


Then, save this as SendMail.vbs in the C drive of the server and, keeping the quotes, make sure to edit the StrFrom, StrTo, and StrSMTP.  Schedule the .bat file and you're done.

' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0

' ------ SCRIPT CONFIGURATION ------
strFrom = "Admin@YOURAGENCY.COM"
strTo = "YOUR-EMAIL-ADDRESS"
strSub = "Check.File Not Found"
strBody = "Incorrect Drive Letter Assigned"
strSMTP = "SMTPHOSTNAME"
' ------ END CONFIGURATION ---------
set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
'objEmail.AddAttachment "x:\path\to\desired\attachment\uncomment\if\using"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
objEmail.Configuration.Fields.Update
objEmail.Send


To test, remove the check.file and run the script, then replace the check.file and run the script.
Mark Piontek, MBA
Director of Information Systems
BS in Information Systems Security

Jeff Zylstra

I knew it would be simple for someone who knew what they were doing and had resources.  I will try this when I get a chance.  Thank you, Mark!

P.S.  +1!
"We hang the petty thieves, and appoint the great ones to public office"  -  Aesop

Jeff Golas

Powershell in server 2012 now supports 2500 commands...yaaay (sarcasm). Cool that its there, but I'm looking at my 1200 page Windows 2k resource book and realize it would probably need to be thicker just for powershell itself.
Jeff Golas
Johnson, Kendall & Johnson, Inc. :: Newtown, PA
Epic Online w/CSR24
http://www.jkj.com