Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SYNC between Two directories

Posted on 2008-10-25
11
Medium Priority
?
1,286 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 1000 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 1000 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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
 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

916 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