HowToForums.net Forum Index HowToForums.net
An Open Source of Knowledge
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HowTo Script NTbackup

 
Post new topic   Reply to topic    HowToForums.net Forum Index -> MS Automation & Scripting
View previous topic :: View next topic  
Author Message
jacob
Site Admin
Site Admin


Joined: 16 Mar 2006
Posts: 73
Location: USA

PostPosted: Wed Apr 05, 2006 1:07 pm    Post subject: HowTo Script NTbackup Reply with quote

NTbackup is a built in feature in Windows NT based OS's which can be used to backup files, folders, exchange information stores and more.
[start>run>ntbackup]

If scipted and used in coordinance with the "Scheduled Tasks", you can automate backups without investing in costly backup software which usualy causes more overhead than efficiency.
"C:\Documents and Settings\Administrator\Start Menu\Programs\Accessories\System Tools\Scheduled Tasks"

Create a bat file on a mapped network drive for example:
X:\Xchangebkup.bat
Were X:\ is the mapped drive.

Take a Look at this example bat file script.
I put this together to run a daily backup job of my MS Exchange information store on a Windows 2000 server to a mapped network drive (x:) ... It takes care of log flushing as well.

Code:

@ECHO OFF
COLOR 5a
MODE CON COLS=80 LINES=50
REM this file will backup the local exchange server using ntbackup, and flush the exch2k logs
REM it will replace the current backup in the mapped drive (X)

echo ###############################
echo ###############################
echo ####  Exchange Backup  ####
echo ####     Start Time:       ####
time /T
date /T
echo ####                       ####
echo ###############################
echo ###############################


C:\WINNT\system32\NTBACKUP.EXE backup "@X:\ExchangeDailyBkup.bks" /n "Daily Exchange BKUP" /d

"description: Exchange Daily BKUP" /v:yes /r:no /rs:no /hc:off /m normal /j "X:\ExchangeDailyBkup.bks" /l:s /f

"X:\ExchangeBKUPbkf.bkf"


echo ###############################
echo ###############################
echo ####  Backup Completed     ####
echo ####   Successfully !!     ####
echo ####      End Time:        ####
time /T
date /T
echo ####                       ####
echo ###############################
echo ###############################



* NOTE
If you mapped a network drive such as I did (X:) then you will have to include a file specifying the files to backup aka Backup Selection Scripts, in my case I am backing up only my exchange server so...
create a file called for example, X:\ExchangeDailyBkup.bks
and put this in it:
Code:

JET <SERVERNAME>\Microsoft Information Store\First Storage Group\

replace <SERVERNAME> with your server name.

You can take a look at this as well:
http://support.microsoft.com/kb/237310/

Otherwise, i recomend you run NTbackup manually at least once, then create some scheduled job.
Take a look at the BKS scripts it creates in "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data"

Then Next step would be to open "Scheduled Tasks" and add the task (point to the bat file) to a conveinient time for the backup operation.


Here are additional Command line options taken from the MS Windows 2000 NTbackup Help File:

"NTBACKUP.EXE /?"
Quote:

Command line parameters
You can perform backup operations at the command prompt or from a batch file using the ntbackup command followed by various parameters.

Syntax:

ntbackup backup [systemstate] "bks file name" /J {"job name"} [/P {"pool name"}] [/G {"guid name"}] [/T { "tape name"}] [/N {"media name"}] [/F {"file name"}] [/D {"set description"}] [/DS {"server name"}] [/IS {"server name"}] [/A] [/V:{yes|no}] [/R:{yes|no}] [/L:{f|s|n}] [/M {backup type}] [/RS:{yes|no}] [/HC:{on|off}] [/UM]

Parameters:

systemstate

Specifies that you want to back up the System State data. When you back up the System State data, all of the System State data is backed up, therefore, the /s switch does not apply. Also, the backup type will be forced to normal or copy.

bks file name

Specifies the name of the backup selection file (.bks file) to be used for this backup operation. A backup selection file contains information on the files and folders you have selected for backup. You have to create the file using the graphical user interface (GUI) version of Backup.

/J {"job name"}

Specifies the job name to be used in the log file. The job name usually describes the files and folders you are backing up in the current backup job as well as the date and time you backed up the files.

/P {"pool name"}

Specifies the media pool from which you want to use media. This is usually a subpool of the Backup media pool, such as 4mm DDS. If you select this you must not use the following switches: /A /G /F /T.

/G {"guid name"}

Overwrites or appends to this tape. Do not use this switch in conjunction with /P.

/T {"tape name"}

Overwrites or appends to this tape. Do not use this switch in conjunction with /P.

/N {"media name"}

Specifies the new tape name. You must not use /A with this switch.

/F {"file name"}

Logical disk path and file name. You must not use the following switches with this switch: /P /G /T.

/D {"set description"}

Specifies a label for each backup set.

/DS {"server name"}

Backs up the directory service file for the specified Microsoft Exchange Server.

/IS {"server name"}

Backs up the Information Store file for the specified Microsoft Exchange Server.

/A

Performs an append operation. Either /G or /T must be used in conjunction with this switch. Do not use this switch in conjunction with /P.

/V:{yes|no}

Verifies the data after the backup is complete.

/R:{yes|no}

Restricts access to this tape to the owner or members of the Administrators group.

/L:{f|s|n}

Specifies the type of log file: f=full, s=summary, n=none (no log file is created).

/M {backup type}

Specifies the backup type. It must be one of the following: normal, copy, differential, incremental, or daily.

/RS:{yes|no}

Backs up the Removable Storage database.

/HC:{on|off}

Uses hardware compression, if available, on the tape drive.

/UM

Finds the first available media, formats it, and uses it for the current backup operation. You must use the /P switch to designate a device-type media pool when you use the /UM switch so that Backup searches for the appropriate type of media (for example, 4mm DDS). When you use the /UM switch, Backup will search the following media pools for available media: Free pool, Import pool, Unrecognized pool, and Backup pool. When available media is found, the search will stop and the media will be formatted and used without prompting you for input. This command is not applicable to tape loaders and should only be used if you have a stand-alone tape device.

Notes

You cannot restore files from the command line using the ntbackup command.
The following switches will default to what you have already set using the graphical user interface (GUI) version of Backup unless they are changed by a command line switch: /V /R /L /M /RS /HC. For example, if hardware compression is turned on in the Options dialog box in Backup, it will be used if /HC is not specified on the command line. But if /HC:off is specified on the command line, it will override the Option dialog box setting and compression will not be used.
If you have Windows Media Services running on your computer, and you want to back up the files associated with these services, see "Running Backup with Windows Media Services" in the Windows Media Services online documentation. You must follow the procedures outlined in the Windows Media Services online documentation before you can back up or restore files associated with Windows Media Services.
You can only back up the System State data on a local computer. You cannot back up the System State data on a remote computer.
If you are using Removable Storage to manage media, or you are using the Remote Storage to store data, then you should regularly back up the files that are in the following folders:
Systemroot\System32\Ntmsdata

Systemroot\System32\Remotestorage

This will ensure that all Removable Storage and Remote Storage data can be restored.



Enjoy !
;-)
_________________
JB
--
"You only see what your eyes want you to see"
Back to top
Display posts from previous:   
Post new topic   Reply to topic    HowToForums.net Forum Index -> MS Automation & Scripting All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group