0

i'm looking for a command that can sync dir1 and dir2, without swapping and deleting the files in those directories.

The current command i'm using is

rsync -av --delete dir1 dir2

which deletes files that belong to dir2 but not dir1. In other words, it will create a duplicate dir1 in a fast way.

say, for example, i add 5 files to dir2 and would like to preserve the order of the command rsync. i want to sync it back to dir1. what options of rsync are available that can help me doing this?

assume i don't want to delete any files in both directories.

  • Try unison – a file-synchronization tool for Unix. – A.B. Jan 19 '16 at 15:44
  • @A.B. : I have, it seems a little confusing but it's a good package. thanks for the recommendation! – kensaii Jan 20 '16 at 20:54
0

You can you this command

if [ -n "$(rsync -anv --delete dir1/ dir2/ | grep deleting)" ]; then \
    rsync -av dir2/ dir1/; else rsync -av dir1/ dir2/; fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.