#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Dallas, TX
    Posts
    135
    Rep Power
    12

    Question Rsync / sync two folders? How do I do this 2-way?


    I'm trying to sync two folders on my system. I know I can use rsync to mirror two folders, but this appears to be only a one-way deal where dir1 is mirrored over dir2. What I need is to sync both dir1 and dir2 so that the latest copies of varies files (along with deletes) will be updated in whichever folder.

    Is there a way to do this with rsync or with some other command?

    Many thanks,
    Steve
    Steve Stringer
    MapTechnica.com - Free mapping tools, zip code finder, and data for your custom mapping application.
    StringerSites.com - Custom website development for small businesses
  2. #2
  3. No Profile Picture
    ......@.........
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Posts
    1,345
    Rep Power
    56
    Suppose your sync dirA with dirB. Then everything in dirB that is NOT also in dirA will be deleted if you start to sync dirA->dirB. The reverse is true, if you start the sync going dirB->dirA.

    You have to have a "master" for a scheme like the one you want to work. You will have to set up a list of files for which dirA always will have the correct version, and another list for dirB. You can create two exclude files - one to prevent dirA->dirB from updating the files in dirB for which it is the master, and another list for
    preventing the update of file that live in dirA for which those files are the master copy.

    I don't know how you handle the problem of files with new names, say a new file pops up in dirB....

    Basically the whole concept as presented has problems. What exactly are you trying to do? Not how you want to do it.
    Last edited by jim mcnamara; December 7th, 2006 at 01:31 PM.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Dallas, TX
    Posts
    135
    Rep Power
    12
    Originally Posted by jim mcnamara
    What exactly are you trying to do?
    In a word, sync. I have files on a desktop and a laptop (both Macs) that I need to keep synchronized. Sometimes I work on one set, other times I work on the other. Seems like this is a solved problem with countless utilities out there. However, rsync is built in and it seems odd that rsync doesn't handle this most basic of synchronization tasks.

    In the end, I have done two things:

    1) I've put both sets of source files under version control with SVN.

    2) For less important things, I plunked down $$$ for a utility called ChronoSync.

    So problem solved, though not in the way I had hoped, nor in a free manner. Seems only logical that rsync should handle this with ease. Guess not.
    Steve Stringer
    MapTechnica.com - Free mapping tools, zip code finder, and data for your custom mapping application.
    StringerSites.com - Custom website development for small businesses
  6. #4
  7. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3887
    Man, how did I miss this thread before?

    Unison is a free tool I use for this (on Linux, but it works on Macs too). I guess it's not much use to tell you that *now* - sorry about that.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Belgrade, Serbia
    Posts
    1
    Rep Power
    0
    Hey,

    I've stumbled upon your post today (I see it dates some 6 years ago ) since I've faced the same problem I figured out how to do the thing you wanted with rsync. You just pass the "-u" option (without quotes) to your parameter list when you execute the command.

    I hope you found the answer already but others like me will surely find this reply useful.

    Best regards.

IMN logo majestic logo threadwatch logo seochat tools logo