SYNC between Two directories

I want to sync files and directores between two directories  even sub directories under   below that directories wtih shell scripts.

example
/mnt/test1
/mnt/test2

both test2 must sync with test1 with shell script and i wat to schdule shell script under cron job every mid night


vadicherlaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chingmdCommented:
You will want to look at the command rsync.  

0
chingmdCommented:
without testing.   this is something of what it'll look like.

rsync avr --delete /mnt/source /mnt/destination
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TintinCommented:
You don't need a script, just define a cronjob as

0 0 * * * rsync -a --delete /mnt/test1 /mnt/test2
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

woolmilkporcCommented:
Hi,
if you don't have rsync installed, you can obtain it hetr
http://rsync.samba.org/
wmp
0
vadicherlaAuthor Commented:
Does rsync also verify the time stamp on file. If we have same file on both directories . i still need to copy the file from A to B because it modified

Thanks
Sudhakar
0
woolmilkporcCommented:
Thats one of the most important features of rsync
0
chingmdCommented:
As well as you can set it to check checksums on the file.  So if for some reason you are not keeping Atime and Mtime on the filesystem rsync will still keep the files in sync.
0
chingmdCommented:
Oh yeah!  it's also a great tool for remotely keeping files in sync..   so you have have an off machine backup.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.