Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Two-way synchronisation

  1. #1
    Join Date
    Oct 2008
    Beans
    59

    Two-way synchronisation

    I've been looking at trying to synchronise various folders between my laptop and netbook over wifi. I suspect I can use rsync for this, but I'm not quite sure how.

    I've seen two guides which seem to have fairly straightforward instructions for doing backups:

    http://a1979shakedown.wordpress.com/...ween-machines/

    https://help.ubuntu.com/community/rsync

    But these appear to be unidirectional, however, what I want is to reflect changes in both directions. That means that when I do backups, I need to keep only the newest version of each file. Also I suspect deleting files could be problematic. Is this possible with rsync?

  2. #2
    Join Date
    Aug 2011
    Beans
    13
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Two-way synchronisation

    I read that rsync is not able to synchronize between two computers who are visible to each other via a network. I am trying to backup folders from a laptop running Windows to my desktop which runs Ubuntu. I would very much like to hear a solution for this.

  3. #3
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,937
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Two-way synchronisation

    Quote Originally Posted by andypi View Post
    But these appear to be unidirectional...
    That's correct. In order to sync you would need to execute two rsync commandas:

    To get the lastest changes from the server:
    Code:
    $ rsync -av -e ssh server:/path/to/dir/ /local/path/
    And this to push your changes to the server:
    Code:
    $ rsync -av -e ssh /local/path/ server:/path/to/dir/
    If you want exact copies also add the option --delete to erase files in the destination that are not in the source.

    BTW, you would need to install OpenSSH in at least one machine (here's is called server).

    Hope it helps,
    Regards.

  4. #4
    Join Date
    Feb 2005
    Location
    Melbourne, Australia
    Beans
    13,505
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Two-way synchronisation

    Quote Originally Posted by andypi View Post
    I've been looking at trying to synchronise various folders between my laptop and netbook over wifi. I suspect I can use rsync for this, but I'm not quite sure how.
    ........
    Install and use the unison package, it uses rsync in the backend but simplifies things with a GUI interface.
    Regards, David.
    Please use the Forum search and Wiki search for immediate help
    Please mark your thread as Solved when appropriate
    New to technical forums?: How To Ask Questions The Smart Way

  5. #5
    Join Date
    Oct 2008
    Beans
    59

    Re: Two-way synchronisation

    Quote Originally Posted by papibe View Post
    That's correct. In order to sync you would need to execute two rsync commandas:

    To get the lastest changes from the server:
    Code:
    $ rsync -av -e ssh server:/path/to/dir/ /local/path/
    And this to push your changes to the server:
    Code:
    $ rsync -av -e ssh /local/path/ server:/path/to/dir/
    If you want exact copies also add the option --delete to erase files in the destination that are not in the source.
    Thanks. Would this not have the problem that if I do a sync from machine A to machine B, if a newer version of file x exists on machine B, then that would be overwritten by the old version on machine A? In addition, if I've erased a file from machine B, would it not then be replaced with the version on machine A, even though I wanted it to be permanently deleted?

    Quote Originally Posted by dcstar View Post
    Install and use the unison package, it uses rsync in the backend but simplifies things with a GUI interface.
    Thanks, this may do the trick. Just a couple of questions:

    1) Can this be scheduled do automatically sync e.g. every night?
    2) Is there any way of running this which does not require me to know the IP address of each machine? If IP addresses are dynamically allocated, or the computers are connected to a new network, is there any way they can be configured such that they'll still be able to find each other?

  6. #6
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,937
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Two-way synchronisation

    Quote Originally Posted by andypi View Post
    Thanks. Would this not have the problem that if I do a sync from machine A to machine B, if a newer version of file x exists on machine B, then that would be overwritten by the old version on machine A?
    As I wrote the example, yes. But there's more options available. For example this would take care of that concern (running from A):
    Code:
    rsync -av --update /local/path/ B:/path/to/dir/
    Quote Originally Posted by andypi View Post
    In addition, if I've erased a file from machine B, would it not then be replaced with the version on machine A, even though I wanted it to be permanently deleted?
    Using the option --delete would help, but not solve that problem. That is a downfall of rsync, you would have to change the order of the commands to achieve the desired behavior. In other words, after changes, you would have to manually sync first in the correct direction.

    For a perfect sync between to working environments, Unison is a much better solution.

    Hope it helps.

  7. #7
    Join Date
    Feb 2005
    Location
    Melbourne, Australia
    Beans
    13,505
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Two-way synchronisation

    Quote Originally Posted by andypi View Post
    .........
    1) Can this be scheduled do automatically sync e.g. every night?
    2) Is there any way of running this which does not require me to know the IP address of each machine? If IP addresses are dynamically allocated, or the computers are connected to a new network, is there any way they can be configured such that they'll still be able to find each other?
    1. Unison has command line functionality, so it should be possible to run it from a cron job.
    2. Finding things with Dynamic IP addresses requires a DNS server to resolve such issues.
    Regards, David.
    Please use the Forum search and Wiki search for immediate help
    Please mark your thread as Solved when appropriate
    New to technical forums?: How To Ask Questions The Smart Way

  8. #8
    Join Date
    Oct 2008
    Location
    Stuttgart, Germany
    Beans
    441
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Two-way synchronisation

    or, just use dropbox: https://www.dropbox.com/

    It's not suitable for *every* situation but it is, for the most part, idiot proof.

  9. #9
    Join Date
    Aug 2011
    Beans
    13
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Two-way synchronisation

    Quote Originally Posted by andypi View Post
    1) Can this be scheduled do automatically sync e.g. every night?
    Unison does not have a built-in scheduler. If you want a tool with a scheduler you could investigate luckyBackup.

  10. #10
    Join Date
    Oct 2008
    Beans
    59

    Re: Two-way synchronisation

    Thanks everyone for the suggestions. Unison works a treat. I just need to set up sshkeys (I think) so it can all be done without me knowing about it and I'll be happy.

    Quote Originally Posted by andypi View Post
    2) Is there any way of running this which does not require me to know the IP address of each machine? If IP addresses are dynamically allocated, or the computers are connected to a new network, is there any way they can be configured such that they'll still be able to find each other?
    This naive question was because I didn't realise I could simply use the hostname to contact a computer on the LAN.

    Quote Originally Posted by Wayne_V View Post
    or, just use dropbox: https://www.dropbox.com/

    It's not suitable for *every* situation but it is, for the most part, idiot proof.
    I already use dropbox, and it is very useful, but I don't want to/can't use it for everything.

    Oh and one more thing... there isn't by any chance a project to get Unison running on Android is there? I couldn't find anything. That would be ideal.

    Edit: Or is it possible to use Unison when only one of the sync'd computers has Unison installed? I have installed QuickSSHd on my Android phone, which is allowing me to access the SD card from my Ubuntu laptop (but only using ports from 1025 and up), however when I try to run a Unison profile to it, it fails...

    Edit2: Hooray! It is very possible to mount the SD card of my (unrooted) phone using sshfs, as long as the SSH server is running on the phone. I can then use Unison to keep everything the way I want it.
    Last edited by andypi; September 1st, 2011 at 02:28 PM.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •