Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to mirror a directory to a remote server

Status
Not open for further replies.

SJSFoxPro

Technical User
Jun 19, 2003
110
US
Need to mirror a directory to a remote server... Servers are HP-UX PA-RISC (64-bit).

We are currently using a script written in Perl to mirror a local directory to a remote server. This script is run every 5 minutes. The problem is that when there are numerous files in the directory, sometimes the copy doesn't complete before the next run is started. The file compare seems to be the bottleneck.

I'm curious if anyone has any alternative suggestions to accomplish this.

Background... Files are continuously created in the directory at varying frequency. Files older than 2 days are purged each night. Files are approximately 8M in size.

The script performs the following tasks:
A shell script first zips the files in the directory to approximately 2M using gzip.
Shell script then calls a Perl script that:
Confirms existence of directories, that they are of directory type, and directories are in readable status for both local and remote paths.
Confirms existence of files in the local directory.
Confirms a match of file, modified date, and size between local and remote paths.
Any non-matching file is copied from the local path to the remote path.

Any thoughts are appreciated!
 
You may consider rsync

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
As PHV says, rsync is a good option.

If the servers aren't too "remote", you might also consider just sharing the directory using NFS. That way no comparing and copying, they both access the same files.
 
Thanks for the suggestions... I'll do some research into using rsync.

Definitely can't share the files. The purpose in copying to the remote server is for backup purposes.
 
You could have the shell script check the system process list for a duplicate instance of itself using something like...

if [ `ps -ef | grep -c ${0}` -gt 1 ]; then
echo "Previous instance of ${0} still running."
exit 1
fi

...this will display the sample error message and stop the new instance before it performs any tasks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top