How-To: Sync folders, local to remote (and vice versa), using Ubuntu 9.10 + Samba + Conduit

I have, temporarily, two workstations at work, a laptop and a desktop. Since I’m not sure yet if what to do with the desktop one, I’m temporarily using both. The problem with that is my files are scattered on these two stations as I continually use it both – the reason why I have to find a way to sync my files somehow…

This is the plan that I came up with:

in the laptop

  • create a shared folder with authentication

in the desktop

  • mount the shared folder (this should be easy to do, no mounting using mount command)
  • run an app that automatically syncs the folders

Both stations are running Ubuntu 9.10, by the way.

Creating the shared folder using Samba

I use Samba in sharing files and I know it supports authentication. Just run this command to install Samba,

sudo apt-get install samba

I did a little googling to enable authentication and it led me to this site. It’s a pretty straight forward tutorial. Just execute how-to-add-a-user step and how-to-enable-the-share-step.

Following the tutorial, I registered my user name in Samba using smbpasswd and I added these lines in laptop’s /etc/samba/smb.conf

    [pros-home]
path = /home/pro
read only = no
force user = pro

I restarted the samba daemon after that:

    pro@ops-laptop:~$ sudo /etc/init.d/samba restart
* Stopping Samba daemons                                             [ OK ]
* Starting Samba daemons                                             [ OK ]


Mounting the share

To verify that the laptop’s shared folder is really shared, I ran nautilus in the desktop and pointed it to laptop’s samba share:

Double-clicking on the shared folder will open an authentication window, I supplied the user name and password and selected the “Remember forever” option. In this way, I don’t have to type the credentials again every time I mount the shared folder.

Note: If you want to look up the user name/password that you’ve saved, go to Applications -> Accessories -> Passwords and Encryption Keys

To mount the shared folder easily and give other applications access to it, I added this line to the desktop’s /etc/fstab

    # my home in ops-laptop
//192.168.0.153/pros-home   /media/remote_home  cifs    credentials=/home/pro/configs/smb_credential,user,noauto,gid=pro,uid=pro  0   0

UPDATE: You need to have the smbfs package installed to mount SMB/CIFS shares, you can install it by running this command, (thanks to MRivera for bringing this up),

sudo apt-get install smbfs

I created a credentials file that contains the user name and password.

    pro@pro-desktop:~$ cat /home/pro/configs/smb_credential
username=pro
password=************
domain=WORKGROUP

I set the permissions also in such a way that it’s not readable by other logged-in users.

    pro@pro-desktop:~$ ls -lh /home/pro/configs/smb_credential
-rw——- 1 pro pro 45 2009-10-30 20:22 /home/pro/configs/smb_credential

I also made sure that the mount point does exists and it’s owned by me.

    pro@pro-desktop:~$ ls -lh /media/ | grep remote
drwxr-xr-x 42 pro  pro     0 2009-11-04 15:05 remote_home

Once the /etc/fstab is configured properly, I can now mount/unmount the shared folder using nautilus. All I have to do now is just click on remote_home to mount it, then click the “eject” icon to unmont it =)

Sync folders using Conduit

Conduit is fairly new application, it’s still in development stage. One thing that I like about it is it’s easy to use. I won’t discuss how exactly I configured it here, you can read the manual online. The example is pretty straight forward.

It’s included in Ubuntu 9.10’s repository, to install it just run:

sudo apt-get install conduit

Here’s a screenshot of my setup in conduit.

For instance, I want to sync my Tomboy notes so I keep these two folders in-sync:
    /home/pro/.tomboy <—> /media/remote_home/.tomboy/

So, that’s it. This the set-up that I’m using right now. So far, things are going well =)

10 thoughts on “How-To: Sync folders, local to remote (and vice versa), using Ubuntu 9.10 + Samba + Conduit

  1. MRivera

    Hello,

    I’m trying to do the same you explain in this article, but I have some question.

    1.- What exactly smbpasswd does?
    2.- When you modify “/etc/samba/smb.conf”, what you’re actually doing is sharing the whole /home/pro folder, right?

    I hope you’d give me a hand.

    Regards.

    Reply
    1. pro Post author

      hi,

      1.- What exactly smbpasswd does?

      I think this link will explain it better: http://ubuntu.swerdna.org/ubusambaserver.html#dbase

      2.- When you modify “/etc/samba/smb.conf”, what you’re actually doing is sharing the whole /home/pro folder, right?

      yes, my intention is to share my home folder, you can always specify a different location, just change the value of path

      Samba has it’s own structure in configuring shares, I suggest you read this link, http://ubuntu.swerdna.org/ubusambaserver.html#shares, just to familiarize yourself with it.

      Reply
  2. MRivera

    One more question.

    I’m syncing two folder, one is the Pictures folder in my desktop (/home/username/Pictures/) and the other is the Pictures folder in my laptop.

    If I add some file to one folder, will sync it fine, but if I delete a folder (ie. /home/username/Pictures/some_folder/), Conduit doesn’t delete it from the destination.

    Is that happening to you too?

    Reply
  3. Pingback: 2010 in review « mundane idiosyncrasies

  4. alex

    Conduit seemed like it might have been the thing to use for this, but it looks like its not being actively developed, it haven’t been updated to the latest ubuntu release and no updates been made for 138 weeks or so..

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s