Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch file

Status
Not open for further replies.

meloadri

Technical User
Apr 7, 2009
120
US
I have 2 files: CAGPR_backup_2010_10_26_224001_2870364.bak and the other is CAGPR_backup_2010_10_27_224001_7778618.bak. I need a batch file that copies only one of the files to a different location on a windows server 2003. I want to include in the batch the switches to eliminate any questions that are prompted in the process. Can someone help me with that please? Thanks in advance.
 
I hope you figured this out by now, but anyway...
You could use xcopy. xcopy /?

/y Suppresses prompting to confirm you want to overwrite an existing destination file.
"xcopy CAGPR_backup_2010_10_26_224001_2870364.bak c:\someOtherDirectory" copies that one file to the other location.
 
I appreciate your response. What you suggestd is a one time copy and I know how to do that. I should have been more specific, I apologize. That file changes every day and I need the copy to take place at 3 am so what I need in the batch are the commands to perform the operation. The 2010_10_26 is the date on the file so that can be figured out. The other numbers, however, I am not sure what they are and they are different for each day. I am not sure if it can be done. Please advise.
 
To run at a certain time each day, make it a scheduled task.

If you want to copy all new files, you could use the archive attribute. That is, by not copying any file that does not have the archive attribute set. For that sort of thing, look at Robocopy. I would recommend using robocopy for any regular copy operations actually, especially if you want to exclude certain things. Check it out. /m does the archive thing
This is installed by default in newer versions of Windows. I think you can even just copy the executable over. The newer versions also have more options than the old version that came in the Resource Kit, I think.

I'm not sure how complex you want to get, such as determining the current date and then see if part of a file name matches that (rather than just looking at when the file was modified). I could probably do that if I had to with a batch file (using FOR and IF commands), but instead I'd really try to get PowerShell installed and do something more straightforward.
 
Thanks for the reply. The text bellow is in batch format running in a task in server 2003. Can you explain it in detail to me? I mean; I know that the batch is calling NTbackup but what does the/n "65tyk21...means? Thanks

C:\WINDOWS\system32\NTBACKUP.EXE backup "@c:\batch\backup\data.bks" /n "65tyk21 Data Backup File" /d "65tyk21 Monday Backup" /v:no /r:no /rs:no /hc:eek:ff /m differential /j "data" /l:s /f "\\cagnas\backup\65tyk21\2_Monday\data.bkf
 
The following will tell you what each parameter means in NTBackup..

Click Start->Run and type

ntbackup /?

and press enter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top