KaliKoder
asked on
Command Line NTBackup
Hello-
I am trying to create a bat script, that would use Windows NTbackup program to do the following using command line:
- backup Data, System State and Exchnage
- Mail a notification upon creation, with log files attached
- Keep three days worth of backups
What I want, is to ask:
1. Is it possible, to know the name of the log file that the backup generats, and store it in a variable. This should include the path of this file as well ?
2. Can anyone please help me with keeping the latest 3 files for NTBackup and delete the rest from a folder ?
Has anyone implimented this using NTBackup ? I know there are better solutions like Veritas available, but NTBackup and a batch script is the only choice I have.
TIA
I am trying to create a bat script, that would use Windows NTbackup program to do the following using command line:
- backup Data, System State and Exchnage
- Mail a notification upon creation, with log files attached
- Keep three days worth of backups
What I want, is to ask:
1. Is it possible, to know the name of the log file that the backup generats, and store it in a variable. This should include the path of this file as well ?
2. Can anyone please help me with keeping the latest 3 files for NTBackup and delete the rest from a folder ?
Has anyone implimented this using NTBackup ? I know there are better solutions like Veritas available, but NTBackup and a batch script is the only choice I have.
TIA
There has been a problem including the log files - I'm not quite sure what it is, but it should be something I can figure out when I get the chance.
I'll post the script shortly.
I'll post the script shortly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Leew, you have got a very good script, it has some good pointers. I would get back to you shortly.
ASKER
Thank you very much for your help Leew. I was able to achieve the objective. I took the lines from your script, where you actually copy the log file generated and give it a unique name with dd:mm:yyyy-mm:ss format. This was very important to me, because having that in the name means no two log file names can be the same. I then copied them to a specific directory at the end of the script and used the mailsend program (a command line freeware) that sends an email to a list of folks listed in a text file, with a predefined message also listed in a text file, and also attaches the files you specify.
Thanks again
Thanks again
Here's a copy of the message I receive after backup:
Backup Request Executed on Fri 05/13/2005 at 1:00:02.93 by administrator
Job Variables:
BackupDrive=J:
BackupFile=J:\all\20050513
BackupLogFile=20050513. 10002.log
BackupType=Differential
JobName=all
SysState=J:\sysstate\20050
Existing backups on this backup disk:
--------------------------
J:\all\20050510. 10002.bkf
J:\all\20050511. 10005.bkf
J:\all\20050512. 10002.bkf
J:\sysstate\20050510. 10002.bkf
J:\sysstate\20050511. 10005.bkf
J:\sysstate\20050512. 10002.bkf
Disk Space Before Backup Began: 52,028,325,888
Executing Commands:
ntbackup backup "@C:\WINDOWS\backups\all.b
ntbackup backup "@C:\WINDOWS\backups\sysst
Disk Space After Backup: 48,510,865,408