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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

advice needed on shell script 1

Status
Not open for further replies.

Tels

IS-IT--Management
Jul 10, 2001
290
GB
Thanks in advance for your help..
I have two RH7.1 webservers running Samba and Apache.
I want to keep both servers web content synchronised by running a script.

I intend to use samba to make the /var/ directory available, and have a script to a) mount the remote share, b) copy (and overwrite) the existing files and folders from the remote /var/ share to the local one

I do not know how to mount an smb share in *nix (normally we use win2k clients) and no experience in writing shell scripts - although I have some in java/perl

The main issue I need advice on is how to copy all the files and folders recursively (I have a notion it involves looping) - has anybody got any advice to get me started?

I really would appreciate help, I'm a fairly new to Linux, but I'm hopelessly hooked.

Regards

Tels

Mixed Linux/Win2000 Network Administrator
 
Samba is only used to share information between Windows and *nix computers. If you want to share information between 2 *nix computers, you need to use something like NFS. Another option is to use something called rdist. rdist is a utility that allows you to maintain identical copies of files over multiple hosts. Typically, content is developed and placed on a single master server and then is distributed to all the other web servers.

If you want to use NFS, you can set the 'shares' up in the /etc/exports file. Here's an example share in /etc/exports....

/home/chris some.host.com(rw)

Here's how you would mount the above share from the other Linux computer...

mount –t nfs linux01:/home/chris /mnt/nfs

linux01 is the NFS Servers hostname. Make sure to restart the NFS server whenever you make changes to the /etc/exports file...

/sbin/service nfs restart

If you want to always mount this share when your server boots, add it to the /etc/fstab file...

linux01:/home/chris /mnt/nfs nfs hard,intr 0 0

ChrisP If someone resolves an issue for you, or was helpful, please click the link on the bottom left hand corner of their post to give them a "star" letting them know they helped you.
 
I forgot to answer the question on the script. If you want to copy all of the data from the NFS share to /var/ write a simple script like this...

cp -fR /mnt/nfs/* /var/
You can execute this script periodically using cron.

ChrisP If someone resolves an issue for you, or was helpful, please click the link on the bottom left hand corner of their post to give them a "star" letting them know they helped you.
 
Top answer! sounds like exactly what I need. I'll wait until the machine has finished compiling and test it out.

Mixed Linux/Win2000 Network Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top