Max10137
asked on
Batch file needed to copy files from one server to another (scheduled job)
I have 2 windows 2000 servers. Server 1 has a bunch of database files in 1 folder. I need a batch file that runs under the scheduler to copy the files to server 2 every couple of hours. This is used for redundancy in case one server goes down, I will have all the files on the other.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hai
For Scheduling use,
At 17:34 "The Command"
The "at" will only work if you're running Windows NT, 2000 or XP.
Under Windows 95 or 98, the "Task Scheduler" program will do the same thing.
One other thing - I've found it's often easier to but the copy command into a batch file, and have AT call the batch file - that way, it's much easier to make changes to what you're copying.
To check locally
You might put it in a batch file with some debug code to verify that it runs:
@echo off
echo Batch ran at %date% %time%>c:\temp\temp.log
xcopy /yesv c:\back01 d:\back01 >>c:\temp\temp.log
Save the batch file to c:\temp\temp.bat and schedule it like:
At 18:34 "cmd /c c:\temp\temp.bat"
Change the time to about two minutes from the current time.
When it's done, check to see if the file c:\temp\temp.log was created
Hope this helps
Regards
Venish
For Scheduling use,
At 17:34 "The Command"
The "at" will only work if you're running Windows NT, 2000 or XP.
Under Windows 95 or 98, the "Task Scheduler" program will do the same thing.
One other thing - I've found it's often easier to but the copy command into a batch file, and have AT call the batch file - that way, it's much easier to make changes to what you're copying.
To check locally
You might put it in a batch file with some debug code to verify that it runs:
@echo off
echo Batch ran at %date% %time%>c:\temp\temp.log
xcopy /yesv c:\back01 d:\back01 >>c:\temp\temp.log
Save the batch file to c:\temp\temp.bat and schedule it like:
At 18:34 "cmd /c c:\temp\temp.bat"
Change the time to about two minutes from the current time.
When it's done, check to see if the file c:\temp\temp.log was created
Hope this helps
Regards
Venish
You might have trouble if the database files are in use. You won't be able to copy the files because they'll be locked and even if you managed to, they would be in an inconsistent state and therefore useless.
What type of database is it? MSQL, Access, etc?
What type of database is it? MSQL, Access, etc?
ASKER
I think I will use Robocopy from the Microsoft Resource kit.
Save this as .vbs and run under scheduler. Enjoy!
dim fso
set fso = createobject("scripting.Fi
fso.CopyFolder "C:\yourfolder", "\\server\share"
set fso = nothing