Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


September 2002

Scheduling Command-Line Win2K Backups

Automate backups on single-tape-drive systems
RSS
Subscribe to Windows IT Pro | See More Backup and Recovery Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

The arrival of a new Windows 2000 server outfitted with Quantum's DLT 7000 tape drive convinced me that it was time to retire the old Windows NT 4.0 server that I'd been using to do tape backups. So, I needed to rescript my backups for Win2K. I didn't expect Win2K's NTBackup to be much different from NT's, but I discovered they are quite different.

My backup approach is simple: Every Monday, I put a tape in the drive. That night, I run at.exe and use the Schedule service to erase the tape and do a full backup. Every subsequent night of the week, I schedule a differential backup. I rotate several tapes and keep a recent backup offsite. Although my approach isn't enterprise-level, it works—and it requires that I write only two batch files: one for the complete backup and one for the differential backup.

The bare minimum syntax for a command-line backup is

ntbackup backup <directory> <tapetype>

where directory is the name of the directory you want to back up (I explain the tapetype value later). Win2K lets you specify the name of a backup selection (.bks) file, which contains a list of directories and files to back up. To indicate that the file is a .bks file, you prefix the file's name with the at (@) character. To make a .bks file, open Notepad and list the directories or files that you want to back up, one to a line. You can add the line

systemstate

to back up the registry and—if the server is a domain controller (DC)—Active Directory (AD). To skip a file or directory, add a line that specifies the name of the file or directory that you want to skip, followed by the /exclude parameter. If I want to back up C:\stuff, C:\mystuff, and the registry but not the C:\mystuff\pst directory, I'd type

c:\stuffc:\mystuffc:\mystuff\pst\ /exclude
systemstate

Next, I'd save the file—I'll call mine C:\files.bks. The only catch is that when I save the file in Notepad, I need to choose Unicode encoding (from the Encoding drop-down list box in the Save As dialog box) instead of the default ASCII encoding. After saving the .bks file, I put it into action by starting NTBackup:

ntbackup backup @c:\files.bks <tapetype>

NTBackup has many other options. I usually add the following options to my differential backup:

/v:yes /hc:on /a /m differential /l:f

The /v:yes option tells NTBackup to verify the backup. The /hc:on option activates hardware compression on tapes that support it. The /a option appends the backup to the tape without erasing existing data—if you don't use the /a option, your backup will overwrite other backups on the tape. The /m differential option tells NTBackup to copy files whose archive bits are set but not to clear those bits. Alternative values for this option are normal, which specifies a full backup and is the default; incremental, which is similar to differential but clears the archive bits; daily, which copies only files that have changed that day (and doesn't clear the archive bits); and copy, which is like a full backup but doesn't reset the archive bits. The /l:f option creates an extensive (i.e., complete) log file. Alternatively, you can opt for /l:s (summary log—the default) or /l:n (no log).

Speaking of log files, another oddity about Win2K's NTBackup program is its hidden log files. You'd expect the log files to be easy to find, but Microsoft has put them in a hidden folder inside a hidden folder inside a hidden folder. Whenever you create a backup, NTBackup creates a log file named backupnn.log, where nn can range from 01 to 10. NTBackup keeps only the last 10 logs, rotating the numbers and overwriting older logs as necessary. You can view the logs by starting the Backup GUI application and choosing Tools/Reports, or you can find the files in Documents and Settings\username\LocalSettings\ApplicationData\Microsoft\Windows NT\Ntbackup\Data (where username is the username of the person who initiated the backup). However, if you use at.exe to schedule the backup, the logs go into Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Windows NT\Ntbackup\Data.

Finally, specify the tape drive to use for the backup. Although you usually have only one tape drive, you still need to specify it. Unlike NT's NTBackup, Win2K's utility delegates control of the tape drive to a subsystem, called the Remote Storage Manager (RSM). And RSM's way of managing tape drives has a side effect: You use different syntax to tell NTBackup to overwrite data on the tape than you use to append a backup. To tell NTBackup to overwrite data, you use

ntbackup backup @c:\files.bks
  /v:yes /hc:on /m differential
  /l:f /p "<tapetype>" /um

where the /p switch specifies that you want to use media from the media pool, and tapetype is a tape-drive description (e.g., DLT, 4 millimeter—mm—DDS). The /um switch tells NTBackup to find the first available media of the specified type, format it, and use it for the backup.

   Previous  [1]  2  Next 


Reader Comments
Excellent article.
I wish I'd seen it before. I've never been able to correctly schedule a backup since my migration to Win2K (of course, previous batch files didn't work anymore)
Thanks

Raymond Warichet August 22, 2002


I know this is oriented toward W2K, but does it apply to WXP as well, or have things changed yet again?

Tom Stewart August 27, 2002


This was useful, but doesn't address the issue of ejecting tapes for operators, this is explained at http://www.jsiinc.com/SUBE/tip2200/rh2265.htm

Also RSM is the 'Removable' Storage Manager.

Nick Swinney August 28, 2002


It would have been helpful to talk about the /UM switch. It stops prompts for user input. Essential to automating backups.

ryan ware October 01, 2002


Excellent! I've trying for two weeks to figure this thing out. One of the stumbling blocks appears to be a mis-print in the SBS Help file. It says the RSM View switch is "/guid_display" instead of the "/guiddisplay" that Mark has demonstrated...I could never get the thing to work. Mark's explanation is perfect!

Gavin Rumble January 11, 2003


Wonderfull !!!!
I can´t even imagine the work you had to discover all this !!
It works very well !!

Nuno Sobral January 21, 2003


How about to create Emergency disk? Can we schedule it?

Cora Li March 02, 2003


This article contains an example that doesn't work.

The option to exclude files or directories is /Exclude, not /exclude. Lowercase is rejected by ntbackup.

Peter Shute April 06, 2003


Good article clear and concise - easy to work with, unlike MS Windows Help Topics!

Eddie Martin November 06, 2003


Pretty smart I must say. Found this very useful. Thanx.

Sugeesh Ariyaratna November 06, 2003


 See More Comments  1   2   3 

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...

How can I stop and start services from the command line?

...


Storage Whitepapers Combining Deduplication and VMware Disaster Recovery: Cascading Savings Improves Cost Effectiveness

Virtualizing Microsoft Exchange Server 2007

StoreVault SnapManagers for Microsoft Exchange and SQL Server

Related Events Storage Consolidation for Your Microsoft Applications: Reducing Cost and Complexity

Virtualization, Automation and Databases

Virtualization Management

Check out our list of Free Email Newsletters!

Storage eBooks A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Keeping Your Business Safe from Attack: Encryption and Certificate Services

Related Storage Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing