We help IT Professionals succeed at work.

NTBACKUP in Command Line to backup only Exchange

Hi,

I have SBS 2003 and I want to write an NTBACKUP command line so I can schedule to backup Exchange's Microsoft Information Store daily.

I don't mind overwritting the exising .bkf file everytime since it will be backed up daily online.

Please, don't direct me to how to articles, just give me the command.

Thanks!

Dan
Comment
Watch Question

Commented:
To where will you be backing it up?  Tape or fixed disk?

Author

Commented:
Fixed Disk. Let's say the folder is C:\Backups\Exchange
Most Valuable Expert 2015
Commented:
Leew, one of EE's most distinguished experts, has a pretty complete script on his homepage which you is very complete and which you could use, you can change it to your needs:

http://www.lwcomputing.com/tips/static/backup.asp
http://www.lwcomputing.com/downloads/download.asp?id=1
Commented:
Quick n Dirty Exchange Backup rotation.  Create a batch file called c:\backups\exchangebackup.cmd and a text file called exchangefull.bks.  Details below.

Obtain Robocopy from micrsooft download center
http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en


------------------------------------------------------------
C:\backups\ExchangeBackup.cmd
------------------------------------------------------------
:: Backup of Exchange Information Store
:: Map file share and delete files that are older than 7 days
net use X: \\fileserver\exchangebackup

:: Make a temp\delete dir, copy old backups >14 days to it, delete temp\delete dir
md C:\TEMP\DELETE
robocopy "X:\" "C:\TEMP\DELETE\" *.* /mov /create /minage:14 /log:"C:\backups\LOGS\deletions.log"
rd C:\TEMP\DELETE /q

::Parse date-time into label to be used for label and filename
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i set tm=%tm::=-% set dtt=%dt%%tm%

:: Backup command line
ntbackup.exe backup "@C:\BACKUPS\EXCHANGEFULL.bks" /d "Daily full Exchange backup" /v:no /r:no /rs:no /hc:off /m normal /j "Daily Exchange Full %dtt%" /l:f /f "X:\Exchange Full %dtt%.bkf"

:: Move job logs to C:\backups\ & name  "Exchange backup date-time.log"
move "C:\Documents and Settings\cbt-backup\local settings\application data\microsoft\windows nt\NTBackup\data\*.log" "c:\backups\LOGS\Exchange Backup %dtt%.log"

net use X: /del /y
exit


------------------------------------------------------------
C:\backups\exchangefull.bks
------------------------------------------------------------
JET YOUR_SERVER_NAME\Microsoft Information Store\First Storage Group\

Commented:
oh sorry, that script maps a network drive X:  to share \\fileserver\exchangebackup.  You can remove that part if fixed disk.

-tom

Author

Commented:
rindi:  
    I couldn't find what I was looking for in http://www.lwcomputing.com/tips/static/backup.asp

tmeunier:
    I don't need to rotate. I want to overwrite yesterday's file with today''s backup. That's because yesterday's file was copied to a remote location already. I'm looking for as much simplicity as possible as this place is not run by techs.

Thanks.
Most Valuable Expert 2015

Commented:
Did you check the 2nd link I posted? You can also find it within the first Link under "Scripts". It'll direct you to download the script which leew made.

Commented:
------------------------------------------------------------
C:\backups\ExchangeBackup.cmd
------------------------------------------------------------
@Echo off
:: Delete existing Exchange Full backup
ECHO Y| DEL "C:\BACKUPS\EXCHANGE\Exchange full.bkf"

:: Backup command line
ntbackup.exe backup "@C:\BACKUPS\EXCHANGEFULL.bks" /d "Daily full Exchange backup" /v:no /r:no /rs:no /hc:off /m normal /j "Daily Exchange Full" /l:f /f "C:\BACKUPS\EXCHANGE\Exchange Full.bkf"

:: Move job logs to C:\backups\ & name  "Exchange backup date-time.log"
move "C:\Documents and Settings\username\local settings\application data\microsoft\windows nt\NTBackup\data\*.log" "c:\backups\LOGS\Exchange Backup.log"

exit

:::::  NOTE that the \username\ portion of the move-job-logs line will be the user that you're using to run the script.  

------------------------------------------------------------
C:\backups\exchangefull.bks
------------------------------------------------------------
JET YOUR_SERVER_NAME\Microsoft Information Store\First Storage Group\

Commented:
By the way, Lee Wilbur's script is most awesome.  And pay no attention to the comments lines in the little batch script I posted; I didn't clean them up for your purposes.

-tom

Author

Commented:
Thanks guys. I'll try this one later tonight.

Author

Commented:
Hi,

I'm running the script below, and it seems to start ok, but after 20-30 seconds it aborts and says it can't find the path.

@Echo off
:: Delete existing Exchange Full backup
:: ECHO Y| DEL "C:\BACKUP\EXCHANGE\ExchangeFull.bkf"

:: Backup command line
ntbackup.exe backup "C:\BACKUP\EXCHANGEFULL.bks" /d "Daily full Exchange backup" /v:no /r:no /rs:no /hc:off /m normal /j "Daily Exchange Full" /l:f /f "C:\BACKUP\EXCHANGE\ExchangeFull.bkf"

:: Move job logs to C:\backups\ & name  "Exchange backup date-time.log"
move "C:\Documents and Settings\administrator\local settings\application data\microsoft\windows nt\NTBackup\data\*.log" "c:\backup\LOGS\Exchange Backup.log"

::exit

Also, it seems to be backing up something in C: and not the Info Store:

untitled.JPG

Commented:
1.  Create C:\BACKUP.  WInthin that create C:\BACKUP\EXCHANGE and C:\BACKUP\LOGS
2.  That script should be saved as C:\BACKUP\ExchangeBackup.cmd
3.   You should also create the file C:\BACKUP\ExchangeFull.BKF which includes the single line:
      JET YOUR_SERVER_NAME\Microsoft Information Store\First Storage Group\

This is the configuration file that is referenced in the script, which tells NTBackup which file selections to run.  The fact that it is selecting C: rather than YourServername | Info Store | First Storage Group is indicative that this file doesn't exist, or is mis-named, or something like that.

-tom

Author

Commented:
I was missing the logs directory!

When you say "3.   You should also create the file C:\BACKUP\ExchangeFull.BKF which includes ..."
you mean .bks, right?

Commented:
I do mean .bks, yes.

Author

Commented:
Hi,

This is how the file looks after a couple of other fixes:


@Echo off
:: Delete existing Exchange Full backup
:: ECHO Y| DEL "C:\BACKUP\EXCHANGE\ExchangeFull.bkf"

:: Backup command line
ntbackup.exe backup "C:\BACKUP\EXCHANGEFULL.bks" /d "Daily full Exchange backup" /v:no /r:no /rs:no /hc:off /m normal /j "Daily Exchange Full" /l:f /f "C:\BACKUP\EXCHANGE\ExchangeFull.bkf"

:: Move job logs to C:\backups\ & name  "Exchange backup date-time.log"
move "C:\Documents and Settings\administrator.TECHINT\local settings\application data\microsoft\windows nt\NTBackup\data\*.log" "c:\backup\ExchangeLogs"

::exit


Now, the backup file is a mere 10K big. I think it's what I mentioned before. Look at my screenshot. It's not backing up the inf store but something (really, nothing) in C:

This is a log file:

Backup Status
Operation: Backup
Active backup destination: File
Media name: "ExchangeFull.bkf created 8/9/2009 at 9:38 PM"

Volume shadow copy creation: Attempt 1.
Backup (via shadow copy) of "C: "
Backup set #1 on media #1
Backup description: "Daily full Exchange backup"
Media name: "ExchangeFull.bkf created 8/9/2009 at 9:38 PM"

Backup Type: Normal

Backup started on 8/9/2009 at 9:39 PM.
Backup completed on 8/9/2009 at 9:39 PM.
Directories: 0
Files: 0
Bytes: 0
Time:  1 second

----------------------


Thanks,

Dan

Commented:
This is sort of bizarre.  I'm getting the same behavior.  Here's how I fixed it, and I have to admit I'm not going to screw with it because I'm lazy, but:

My ExchangeFull.bks file does this, when created in Notepad.  But when I create the same thing in NTBackup, by making the selections in the GUI - selecting the information store - and then say file > Save as and I save it as C:\Backup\ExchangeFull.bks, THAT one works.  The other strange thing is that when I type it in notepad, it's 59 bytes, but when I create it in NTBackup and save it, it's 122 bytes.  To look at them in notepad, they're identical.  

So, I have to throw up my hands and say, try running the GUI once, selecting your Info Store, and select Job > Save Selections As > c:\backups\exchangefull.bks.  Then try again.  For me, it worked.

Author

Commented:
Will try that. Thanks.

Author

Commented:
It didn't help.

Author

Commented:
Hi,
I just scheduled it using NTBACKUP's gui and it's working fine.
Thanks!