Announcement

Collapse
No announcement yet.

Syncing laptop and desktop

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Syncing laptop and desktop

    Hey guys\gals,

    I am fairly new to linux, but have fully converted from Microsoft. Linux is awesome. Anyway here's my problem; I have a laptop that travels with me everywhere (mostly college, work, etc, running kubuntu 8.04) and a desktop at home (also running kubuntu 8.04). I want to keep the home dir on both machines in sync. My ideal solution would be to have it sync automatically. So when I come home at night I can dock my laptop, or connect to my wireless network without the dock and have a cron job (just as an example) that is running, notices that I'm connected to my network, and it automatically starts syncing my laptop home dir with my home dir on my desktop. Is rsync the way to go? If so does someone have a shell script that does this? What are my options? Can this be accomplished? Is this a stupid idea? Also, this isn't a big deal or requirement, but would it be possible to do the same sync over an ssh tunnel? I'm a big user of tunnels when I'm not at home to securely connect to my home network. Any thoughts, suggestions, advice would be much appreciated.


    Thanks,

    Mobi

    #2
    Re: Syncing laptop and desktop

    rsync has no problems running over ssh. however, you will need to use public key authentication if you want to do it automatically.

    There are two tools I would suggest, each with advantages and drawbacks

    rsync is one. unison is another.

    rsync is designed to be one way. You have to run it twice to copy changes both ways.
    unison is both ways by design. however, it makes it scarily easy for accidental deletions to be synchronised. hence why I use rsync.

    and yes, a shell script will do fine. the best way would be to somehow get it run when the network connects, but I don't know how to do it. so using cron to run it periodically should be fine.

    another gotcha with rsync is that it matters whether or not you have a trailing slash

    '/path/to/files' means the directory 'files', whereas 'path/to/files/' means the CONTENTS of the directory 'files'

    Here's a script that may do the trick, but it's untested so be careful

    Code:
    #!/bin/bash
    #pulls to this machine, then pushes to remote
    
    # -vv doubly verbose, will write what is done and not done
    # --rsh=ssh makes it use ssh
    # -a archive, preserve everything (but see --chmod)
    # -u update, don't overwrite a newer file with an older! do make sure your computer's clocks are keeping the same time or this might break
    rsync -vv --rsh=ssh -a -u pip.srcf.ucam.org:/remote/path/to/files /local/path/to/files >> /local/logfile
    rsync -vv --rsh=ssh -a -u /local/path/to/files pip.srcf.ucam.org:/remote/path/to/files >> /local/logfile
    I am running Ubuntu 8.10 (yes Gnome) with upgrades applied daily about 0900 UK time. Hardware is Dell Precision 420, 2x 800 MHz PIII, 512 MB RDRAM, nVidia GeForce 6800 128 MB AGP graphics, 18GB SCSI and 500GB IDE HDDs, DVD burner, Hauppage TV card.

    Comment


      #3
      Re: Syncing laptop and desktop

      @mobius 122: great idea

      @cantab: awesome where can i find a tutorial for ssh(server setup), as i have never used it b4, and could i use this method to sync w/ an xp machine too? (perhaps via a smb share on the xp machine)

      Mark Your Solved Issues [SOLVED]
      (top of thread: thread tools)

      Comment


        #4
        Re: Syncing laptop and desktop

        Setting up an ssh server is effortless. Just install openssh-server

        There are a few things worth doing for security; namely disallowing root logins (ubuntu defaults to a locked root account anyway), and I think there's a way to lock out anyone trying to brute-force the password - search adept for 'ssh' and it should be there.

        What does need setting up is public key authentication. Here is the guide I folllowed:

        http://sial.org/howto/openssh/publickey-auth/

        To sync to an xp machine would be slightly different. If you're using an smb share then you need to mount it on the client, and then do the sync between the local and the mounted directory. In this situation you need to explicitly tell rsync to use its compression and stuff; it will think the mounted directory is local and so won't bother by default.

        Alternatively you could run an ssh server on the windows xp machine. I don't know how to do that though.
        I am running Ubuntu 8.10 (yes Gnome) with upgrades applied daily about 0900 UK time. Hardware is Dell Precision 420, 2x 800 MHz PIII, 512 MB RDRAM, nVidia GeForce 6800 128 MB AGP graphics, 18GB SCSI and 500GB IDE HDDs, DVD burner, Hauppage TV card.

        Comment


          #5
          Re: Syncing laptop and desktop

          sweet i will give it a shot and report back when i get somewhere with it i would prolly not bother w/ compression as it would be over LAN even if i use my wifi i shouldn't have more then 100 mb to sync
          and i never knew i could mount an SMB share thats good to know .. but how i would assume i create mount point then do a mount smb:/<server>/<dir> /<mountpoint ?? ok yea i might need a sudo there too lol
          Mark Your Solved Issues [SOLVED]
          (top of thread: thread tools)

          Comment


            #6
            Re: Syncing laptop and desktop

            I should clarify that it's not exactly 'compression' that rsync does - rather it transfers only files, and even parts of files, that have changed. True, on a LAN it doesn't really matter.

            As for how to mount it, that's not how. rather, you need the smbfs package installed, then the mount.cifs manpage should give some pointers
            I am running Ubuntu 8.10 (yes Gnome) with upgrades applied daily about 0900 UK time. Hardware is Dell Precision 420, 2x 800 MHz PIII, 512 MB RDRAM, nVidia GeForce 6800 128 MB AGP graphics, 18GB SCSI and 500GB IDE HDDs, DVD burner, Hauppage TV card.

            Comment


              #7
              Re: Syncing laptop and desktop

              coolie thx
              Mark Your Solved Issues [SOLVED]
              (top of thread: thread tools)

              Comment

              Working...
              X