Vincent D
asked on
Script to copy folder content every 5 minutes
Hi,
We have a folder on a particular server that moves files in and out of a particular folder all day long. We would like to use a batch file/script that would copy all content to an archive folder somewhere else on the server/network just as a precaution.
Can anyone direct us to examples of batch files/scripts that work great for such a task?
We have a folder on a particular server that moves files in and out of a particular folder all day long. We would like to use a batch file/script that would copy all content to an archive folder somewhere else on the server/network just as a precaution.
Can anyone direct us to examples of batch files/scripts that work great for such a task?
Why not just create a simple BAT file with the COPY commands (or XCOPY) that you need to copy the files, and then use Windows Scheduler to run it every 5 minutes.
If you need help with the exact syntax and options for the COPY, we'll need a little more info about what files are involved, how are they selected, are there subfolders, are they moved / deleted or copied, etc.
~bp
If you need help with the exact syntax and options for the COPY, we'll need a little more info about what files are involved, how are they selected, are there subfolders, are they moved / deleted or copied, etc.
~bp
ASKER
It is a bit more complicated as the files that show up in this folder on this particular Server 2003 server are periodically transferred from another server thru a batch process that runs periodically. The files that show up are only in the target folder for a short (5min) period of time before being moved out of the target folder and on to another third server.
Would using the batch file copy process reliably get all files without running into issues?
Would using the batch file copy process reliably get all files without running into issues?
ASKER
Scenario Example which has files coming and going to and from all 3 servers
Server A = Redhat Linux Server with Samba
Server B = Windows 2003 Server (that contains target folder we are looking to archive EVERYTHING that comes in and out of it). One folder for incoming and another seperate folder for outbound.
Server C=Hosted by third party thru secure internet VPN link.
Server A = Redhat Linux Server with Samba
Server B = Windows 2003 Server (that contains target folder we are looking to archive EVERYTHING that comes in and out of it). One folder for incoming and another seperate folder for outbound.
Server C=Hosted by third party thru secure internet VPN link.
xcopy is a reliable program. The only thing is that the time window you said 5 mins should be enough to copy the intermediate files. If you have larger/too many files, it may not work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are able to use Powershell, you can also use the FileSystemWatcher class to monitor a folder for changes, and act accordingly. See here for an example:
http://gallery.technet.microsoft.com/scriptcenter/Powershell-FileSystemWatche-dfd7084b
Ultimately though, I agree with Bill....the best way to ensure accuracy would be to modify your incoming and outgoing automatic processes (batch files?) to add the archiving code to them.
Regards,
Rob.
http://gallery.technet.microsoft.com/scriptcenter/Powershell-FileSystemWatche-dfd7084b
Ultimately though, I agree with Bill....the best way to ensure accuracy would be to modify your incoming and outgoing automatic processes (batch files?) to add the archiving code to them.
Regards,
Rob.
@echo off
xcopy C:\Source\Folder Z:\Destination\Folder /s /e
You can use the task scheduler to call this batch file every 5 minutes or (your desired time).
z:\ can be any local drive or network shared drive.