Solved

Batch file needed to copy files from one server to another (scheduled job)

Posted on 2004-04-23
5
2,031 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:Max10137
5 Comments
 
LVL 3

Expert Comment

by:Level10Access
ID: 10902093
Hey there,

Save this as .vbs and run under scheduler. Enjoy!

dim fso
set fso = createobject("scripting.FileSystemObject")
fso.CopyFolder "C:\yourfolder", "\\server\share"
set fso = nothing


0
 
LVL 14

Accepted Solution

by:
JohnK813 earned 250 total points
ID: 10902339
You could also use a DOS batch file like this.

If placed on Server 1:
copy "c:\folder\*" "\\server2\share\folder\."

If placed on Server 2:
copy "\\server1\share\folder\*" "c:\folder\."

Level10's script is also correct, if you want to use that.

Now, do you need any help with the scheduler as well?
0
 
LVL 4

Expert Comment

by:venishjoe
ID: 10902473
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
0
 
LVL 1

Expert Comment

by:jmwiens
ID: 10902511
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?
0
 

Author Comment

by:Max10137
ID: 10904252
I think I will use Robocopy from the Microsoft Resource kit.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now