Automated Backups with Windows and Ubuntu, Part 2

Getting SyncToy to synchronize its paired folders with Ubuntu is a relatively easy process, but it requires some initial setup. Basically, SyncToy will utilize a network drive that is mapped to your Ubuntu machine. Luckily, Samba makes this really easy.

Setup The Ubuntu Machine

Setting Up Samba

The most recent version of Ubuntu ships with Samba already installed, so you can skip down to the configuration section if you’re already running Ubuntu 8.04. If not, launch a terminal - there are a couple of packages that must be installed.

sudo apt-get install samba smbfs

This is all that’s required to install Samba on the machine. Before you can begin sharing directories with other Windows machines, some initial Samba configuration is required. First, open the Samba configuration file with whatever text-editor you favor the most.

sudo gedit /etc/samba/smb.conf

Once the editor opens, find the area of the file that manages security and authentication. Uncomment the line that sets security equal to user. Also setup a map for usernames. The revised version of the configuration file should look like this:

####### Authentication #######
# “security = user” is always a good idea.
# This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/
# ServerType.html
# in the samba-doc package for details.
security = user
username map = /etc/samba/smbusers

The last piece of Samba configuration is to setup a username and password. First, in the terminal, setup the password with this command:

sudo smbpasswd -a <username>

I recommend using your Ubuntu username, but you can technically use whatever you want. Lastly, setup the smbusers file that we specified in the mapping in the Samba configuration file. To do this, open the smbusers file with this command:

sudo gedit /etc/samba/smbusers

In this file, map the username of user you are currently logged in as to the username specified when setting the password above. The line should look like this:

<username> = “<username>”

This finishes setting up Samba; however, before mapping the drive from Windows, a directory must be shared from the Ubuntu machine.

Sharing Directories in Ubuntu

This step is extremely easy. For the purposes of this post, I’m assuming that the directory to be mapped to the Windows machine is located in your home directory.

So, launch your favorite file manager and navigate to your home directory. If you’re planning to create a new directory for backup, then do that now. Right-click on the directory that you wish to share and select “Sharing Options.” In the window that appears, perform the following actions:

  1. Check the option to Share this folder
  2. Specify the share name. Usually, this is the same name as the directory.
  3. Check the option to Allow other people to write in this folder.
  4. Click Modify Share. If you receive a net 255 error, then you’re attempting to share a directory with a name that matches an existing username on the system and you’ll need to choose another name.

Once this is done, the Samba/Ubuntu configuration should be complete.

A quick note: Some people seem to experience host name problems when they’ve setup Samba on their existing Ubuntu installation. To rectify this problem, edit the hosts file in your favorite text editor by entering this command:

sudo gedit /etc/hosts

In that file, verify that the first two lines read like this:

127.0.0.1 localhost <your-machine-name>
127.0.1.1 <your-machine-name>

Configuring Windows

Mapping Ubuntu’s Directory to Windows

From your desktop, double-click on My Computer. When the Explorer window appears, do the following:

  1. Click on the Tools menu and select Map Network Drive….
  2. In the next window, select the drive letter that you wish to refer to your Ubuntu shared drive
  3. In the folder field, enter the name of the machine and the shared directory in this format \\your-machine-name\shared-directory-name
  4. Specify whether or not you want Windows to automatically connect to the Ubuntu machine at logon.
  5. Click Finish

Permitting everything has been setup correctly, you should a new drive should appear in Windows Explorer that maps to the shared directory in Ubuntu.

Setup SyncToy To Backup to Ubuntu

Configuring SyncToy is easy - now that there is a drive mapping from Windows to Ubuntu, it can be treated like any other Windows directory.

  1. Open SyncToy and click on Create New Folder Pair.
  2. For the left folder, select the directory on your Windows machine that contains the files you wish to backup.
  3. For the left folder, select the recently mapped drive.
  4. Select the synchronization configuration option as mentioned in Part 1.
  5. Name the folder pair.

If you wish to schedule asynchronous backups, then setup a second scheduled task using the process that was outlined in Part 1; otherwise, you’re all done.


 
 
 

One Response to “Automated Backups with Windows and Ubuntu, Part 2”

  1. Thomas Duff
    8. June 2008 at 12:03

    Tom

    I successfully completed the Setting up Samba section

    I then attempted the Sharing Directories in Ubuntu and ran into the following.
    When I got to step 2 I got a You need to install Windows Sharing Service error.
    When I selected install it failed
    I then did the hosts changes noted below under sudo gedit etc/hosts
    Then there is no “Modify Share” as noted in Step 4
    There is a “Create Share” which I attempted.
    When I attempt to ‘Create Share” I get the following error:
    Samba’s testparm returned error1:
    Load smb config files from /etc/samba/smb.conf
    Processing section “[printers]”
    Processing section “[print$]”
    Loaded Services OK
    Error: lock directory /var/run/samba does not exist
    Error: pid directory /var/run/samba does not exist

    I don’t know where to go from here. Can you help?

    This is a brand new Ubuntu 8.04 install with updates added

    Thanks in advance.

    Duffmeister

Leave a Reply