Ubuntu: How to sync files on 2 computers using an ethernet cable (offline)?



Question:

I have a laptop running Ubuntu 12.04 and a netbook running Ubuntu 12.10. I want to sync some folders from my laptop on my netbook, connecting them with an ethernet cable.

Both computers are offline, and I don't want to (eventually) share files through my office LAN.

What options do I have? Can I use Unison? What do I have to do in order to "connect" the two computers? (i.e. I have to manually set IPs on them, IPv4 settings, and so on).


Solution:1

Using Timo Kluck's instruction (-> see below!) I was quickly able to set up a connection between my two laptops. However rsync proved not to work for me like this. But I found another solution on the internet, using a adhoc http server:

  1. On the computer where the file you want to transfer is located: cd into the directory where the file is located
  2. then execute the command

    python -m SimpleHTTPServer 8000  

    in the same terminal window. This starts up a simple HTTP Server reachable on port 8000 which makes accessible the files in the current folder you cd'ed to, and also the subfolders.

  3. To transfer the file, on the other computer, in terminal execute the command

    wget -r [ip of server computer]:[port number chosen above]/[file name]  

    where you could replace [file name] also with [subfolder1]/[subfolder2]/[file name 2] if you want to download a file out of a subfolder.

With this method I was able to get 60 - 100 MB/s.


Solution:2

You do need to set IP addresses manually, both on netbook and notebook. The addresses must be on the same subnet.

As for the sync, you may use RSYNC over SSH to achieve this. The command is as follow:

$ rsync -avzgroupP -e ssh origin_folder login@dst_machine:destination_folder  

Pay attention to the folder notation. If you add the / to the end of the directory, RSYNC will start to copy/put files from this point on but if you omit the /, then RSYNC will copy the folder itself and onward.


Solution:3

Here's how to set up the network connection.

  1. connect both computers using any ethernet cable.
  2. on each computer do the following:

    • select your network icon and choose the 'Edit...' option

    • choose 'Add...' in the 'Cable' tab

    • in the IPv4 tab, select 'Manual' for the method, and add the data

      ip-address: 192.168.1.1    (and 192.168.1.2 for the other computer)  netmask: 255.255.255.0  

      leave the rest empty

    • uncheck the box 'automatically connect'

    • call your new connection something like "point-to-point connection (ip-address 192.168.1.1) and choose 'Save'
  3. select this connection on both computers

  4. Use rsync as in fboaventura's answer

It may seem easier to just assign the ip-address and netmask using ifconfig. However, I found out that my network dropped all the time, and I think that was because of NetworkManager interfering. The method above lets NetworkManager be aware of the way you want it to be set up.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »