Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I've read numerous posts and found a couple of websites on creating batch files but I still dont feel comfortable making one yet.
I have 2 servers in my network. I need to backup a certain folder (and all its contents) from one server to the other. I would like for it to do this M-F nightly at 9pm(I believe I would do this part through task scheduler though). I would like for it to overwrite itself each time also.
The folder I am wanting to backup is located:
\\Server2\F:\sun\backup
The destination folder I would like this folder to go to is:
\\server1\D:\SCbackup
The purpose for me doing this is because I dont have remote backup for my Veritas software to backup server2. I just want to copy that folder from server2 to server1 before the nightly backup occurs on server1 through Veritas.
Also, if anyone knows of a good website that could teach batch files to a beginner I would appreciate a link.
Thanks,
Joe

Not sure I'd use a batch file but many people do.
Start here maybe.
http://www.microsoft.com/windowsxp/...I read it wrong and answer it wrong too. So get off my case you goober.

Here's a batchfile I use at home, and have used for clients under similar circumstances to your own.
First, you have to create the backup set in ntbackup. Then schedule it. Open the scheduled backup to copy the command line from it to use in the backup batchfile.
***begin batchfile***
@echo offrem clear mapped network drive to destination (backup) folder
net use w: /d /y
rem map network drive to backup folder on server
net use w: \\server\username /persistent:yes
rem perform the backup
C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\Daily Backup.bks" /n "Daily Backup.bkf created 6/6/2005 at 11:04 AM" /d "Set created 6/6/2005 at 11:04 AM" /v:yes /r:no /rs:no /hc:off /m normal /j "Daily Backup" /l:s /f "C:\Backup\Daily Backup.bkf"
rem copy the backup to the server
xcopy c:\backup\"daily backup.bkf" w:\ /y
rem release mapped drive
net use w: /d /y
rem exit the batch file
exit
***end batchfile***You would change the line mapping the drive to reflect your shared (destination) folder:
\\server1\D:\SCbackupNote: You shouldn't need drive letters in your mapping as you shouldn't have more than one shared folder of the same name on the same server, regardless of number of available drives. This is to avoid confusion. So the mapping should look as follows:
\\server\SCbackupOne thing to note, in my batchfile I have it release the mapped drive first, then map it and release it again at the end of the batchfile. I've found windows tends to behave erratically at times with mapped drives and found this the best way to ensure a consistent drive mapping.
You will also have to tweak the path in the xcopy command to reflect the location of your backed up file.

Thank you very much Curt. This is going to help me a lot. The only thing I may need to change is the actual backup you are performing. The files I am copying from the f:sun\backup are the actual backup files themself. The program that uses this DB already performs the backup and puts it in this location. All I need to do is simply copy that backup folder over to the other server.
But I will be able to pick through your batch file and find what I need. Thanks.
I do have one more question you may be able to help me with. Is there a way to copy a folder and all its contents but omit a certain file or folder within that folder? I think I saw the code somewhere but dont remember where.
Thanks,
Joe

All I need to do is simply copy that backup folder over to the other server.
Even easier then. If the DB backup is a single file, you'll want to ook into that folder, find out the file name, remove the "perform backup" section from the batchfile (leaving only the drive mapping and xcopy parts) and put the correct path/filename in the "xcopy" portion.
If it turns out to be multiple files within that folder I highly recommend archiving it using winzip (or winrar or something like that) first, then copying the .zip file over.
Don't forget to test it to verify it's working properly prior to scheduling it.
Hmmm........I don't know about skipping particular files or folders. I'm quite sure it can be done but I'm not that good of a batchfiler. My suggestion is you message "Mechanix2go" here at computing.net and ask him. He's a first class batchfiler and if anyone can help you out, he can.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |