Solved

SYNC between Two directories

Posted on 2008-10-25
11
1,248 Views
Last Modified: 2012-06-22
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


0
Comment
Question by:vadicherla
11 Comments
 
LVL 9

Expert Comment

by:chingmd
ID: 22806303
You will want to look at the command rsync.  

0
 
LVL 9

Accepted Solution

by:
chingmd earned 250 total points
ID: 22806304
without testing.   this is something of what it'll look like.

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

Assisted Solution

by:Tintin
Tintin earned 250 total points
ID: 22806325
You don't need a script, just define a cronjob as

0 0 * * * rsync -a --delete /mnt/test1 /mnt/test2
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22807863
Hi,
if you don't have rsync installed, you can obtain it hetr
http://rsync.samba.org/
wmp
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:vadicherla
ID: 22807958
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22807999
Thats one of the most important features of rsync
0
 
LVL 9

Expert Comment

by:chingmd
ID: 22817493
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
 
LVL 9

Expert Comment

by:chingmd
ID: 22817499
Oh yeah!  it's also a great tool for remotely keeping files in sync..   so you have have an off machine backup.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now