|
Answer» Hi, I am trying to come up with an easier solution to moving files from one system to another when they are completely created.
History: I WORK for a very small company that tests software on many different OS platforms Windows,Linux,Unix All flavors dating from OLD-Outdated to Newest Currently on some of the older systems we use Winzip Command line to backup certain directories to a Redhat Linux Samba Shared Drive. This has problems.....Doing this directly causes corruption to the Zip file Not SURE why yet, but it does. If I change the destination to a windows server the Zipped files do not get corrupted. So..... Currently I do a few things. Create the Zips sending them to a windows server Move them from the windows server to the Samba Shared Drive. (This method does not cause corruption and was able to restore file successfully)
the PROBLEM I have is This is a manual process. I would like to automate the process of moving the files from the Windows Server to the Samba share when there are files present and completed.
To Avoid having to write individual Bat files and schedule them to run after the create of the files has been completed. I need a way to automate the process of moving files from one system to another.
Here are my thoughts on the process:
This script would need to be run "LIKE" a service in the background checking every 60 minutes or so (Could be a scheduled task set to run every hour or so)
Check if Files exist in Backup Tree Options for Backups are daily, weekly, monthly.
The Sub directory name is actually the Host name and Drive ie system1_c system1_d
The Destination directory is a NETWORK mapped Drive and same SubDir name
Maindir | | |-Subdir1 | | | |-new_daily_`Subdir1`.zip | |-new_daily_`Subdir1`.log | | |-Subdir2 | | | |-new_daily_`Subdir2`.zip | |-new_daily_`Subdir2`.log | | |-Subdir3 | | | |-new_daily_`Subdir3`.zip | |-new_daily_`Subdir3`.log | | |-Subdir4 | | | |-new_daily_`Subdir4`.zip | |-new_daily_`Subdir4`.log | | |-Subdir5 | |-new_daily_`Subdir5`.zip |-new_daily_`Subdir5`.log
Using a BAT file scheduled to run after I "think" the file is completly zipped is not the answer as it could still be open. Can you point me to some samples of scripts that may do pieces of what I am trying to accomplish...maybe I can modify them to do what I need.
Your thoughts and responses are appreciated.
Thanks again RobertMCol
Using the scheduler and batch files presents a problem. Unless you persisted the data, the batch file would have no previous knowledge of the contents of the directory. How would it determine which file to move?
If you could see your way clear to have one directory for the zipped files, you could create a VBScript event monitor. As each file arrives in the directory, the script could fire off the move operation.
Code: [Select]strComputer = "." set fso = CreateObject("Scripting.FileSystemObject") Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE " _ & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _ & "TargetInstance.GroupComponent= " _ & "'Win32_Directory.Name=""c:\\\\Maindir""'")
Do Set objLatestEvent = colMonitoredEvents.NextEvent arrFile = Split(objLatestEvent.TargetInstance.PartComponent, "=") fname = arrFile(UBound(arrFile)) fname = Replace(fname, """", "") fname = Replace(fname, "\\", "\") Wscript.Echo "File Created: ", fname Loop
The script above monitors a directory and notifies the user a creation event has occurred. With a little modification, you could copy the files to their proper subdirectories and then move the files to the Samba server. You already have a good naming convention so the proper paths could be constructed reasonably easy.
The Scripting Guys can probably explain how this works better than me.
Hello Sidewinder, Thanks for your response......
You nailed it on the head when stating that
Quote the batch file would have no previous knowledge of the contents of the directory
Which is why I was asking my question here.
In an ideal world, the script would need to monitor creation events in multiple directories and respond to those events once the file was completely written. Which is another question.... How would the move script know when the file was complete. (ie stat the file checking the modify date or change date)
I do appreciate your response and pointer to the scripting guys
I will try and modify the Event monitor script to do what I am asking as well as ask the scripting guys for assistance.
Once I do either get it working or am forced to follow a different path I will update this thread so all can benefit.
I appreciate your HELP and have enjoyed reading these forums. I look forward to coming here as often as permitted. RobertMCol
|