Resync data on File system

Hi All,

I have two mount points have the same data with little changes between them

/appabc1
/appabc2

Both of them have the same data, there is some little changes on the data between them

I want /appabc2 to has the same data of /appabc1 exactly including to those little changes !

How to can I Resync the data between them?

Pls advice in that... :slight_smile:

Well, you can delete everything and copy afresh:

rm -rf /appabc2/*;cp -rp /appabc1/* /appabc2

or go by modified date, checksum or bit for bit compare of every file. Do you need to trim excess files in /appabc2/ ? New files need to be added, of course. Can there be new dirs? See man cpio pass option with updates only, which does a lot of this. The rsync command seems overkill for local files. Off the cuff = untested, files only, exact compare:

(
  cd /appabc1
  find . -type f
  cd /appabc2
  find . -type f
 ) | sort -u | while read f
do
 f="${f#./}"
 if [ ! -f "/appacb1/$f" ]
 then
  rm -f "/appabc2/$f"   # prune
  continue
 fi
 if [ -f /appabc2 -a "$(cmp "/appacb1/$f" "/appabc2/$f" 2>&1)" = "" ]
 then
  continue
 fi
 cp -p "/appacb1/$f" "/appabc2/$f"
done
 

you can use rsync for this purpose

rsync --verbose --progress --stats --recursive --times --links --update --perms --owner --group /dir1/ /dir2

older Files will not be copied over newer ones, and no files will be deleted ( if you want this, use --delete)

It's good command , but I want accurate answer about this command

[LEFT]If I have file in the /dir1 called  appfile.log  has size :20MB[/LEFT]
[LEFT]And in  /dir2 appfile.log  has size :15MB[/LEFT]
[LEFT]If i re sync the directories by the below command 

[/LEFT]

rsync --verbose --progress --stats --recursive --times --links --update --perms --owner --group /dir1/ /dir2
[LEFT]That mean the appfile.log will be updated and synced in /dir2 and will take the same size ?[/LEFT]

yes - rsync works with ctime - when the log on the original was changed later than on the destination, than the smaller log will be replaced.

Regards
zxmaus

it's giving me this error

 
ksh: rsync: not found

is it requiring to install rsync-3.0.6-1.aix5.3.ppc.rpm ?

---------- Post updated 04-24-11 at 03:04 AM ---------- Previous update was 04-23-11 at 04:53 AM ----------

Command got hanged in some bad files !

Is there any option to ignore any unreadable files or bad files?!

Pls advice!

try to run fsck, to eliminate those "bad" files, or try to remove them manually

cheers