This is the second post about setting up a server for home or small business with SAMBA. If you haven’t seen the 1st post read it here :

http://blog.sanjaya.me/setting-up-a-server-for-home-or-small-business-1-configure-samba-file-server-with-ubuntu/

Printer sharing with SAMBA

I have already installed HP Deskjet 3920 printer in my server machine and enabled sharing. (Open “Printing” application >> Right click on the printer, see whether sharing is enabled).

Printers in Ubuntu

Printers in Ubuntu

 

As we are giving anonymous access to printers first create a user account for remote print jobs

 /usr/sbin/adduser --system --disabled-password smbprint

Then append the following lines to the end of the Global Settings.

printcap name = cups
printing = cups

And now we’ll share the printers. Add the following code to the end of the file

[printers]
browseable = yes
printable = yes
public = yes
create mode = 0700
guest only = yes
use client driver = yes
guest account = smbprint
path = /home/smbprint

Now your smb.conf file must look like this.

#===============Global Settings===========
[global]
workgroup = workgroup
server string = DI Server
; netbios name = DI-Server
security = share
map to guest = bad user
dns proxy = no
; encrypt passwords = yes
guest ok = yes
guest account = di
printcap name = cups
printing = cups

#===============Share Definitions===========
[DI Files]
path = /media/sda6/DI-Files
browsable = yes
writable = yes
guest ok = yes
read only = no
create mask = 0755

[printers]
browseable = yes
printable = yes
public = yes
create mode = 0700
guest only = yes
use client driver = yes
guest account = smbprint
path = /home/smbprint

Done! Restart the SAMBA services and check from a windows machine.

sudo restart smbd
sudo restart nmbd
Printer Shared

Printer Shared

 

So we are done with file printer sharing. Are we really ?

Try restarting the machine and see from the windows machine. Most of the times you won’t see printer there. If you restart SAMBA manually you will see it again. This happens because CUPS service is not started when samba is started while booting.

Fix for the problem “Printer not showing up until I restart SAMBA”

Give the following command.

 sudo gedit /etc/init/smbd.conf &

In the smbd.conf file just after pre-start script add the following line

sleep 10 
Editing smbd.conf File

Editing smbd.conf File

Now restart and see.

File Synchronization with Unison

To regularly backup the files I’m using Unison. Actually what I hope is getting the files synced from a source to a destination location in a particular time daily.

Get the GUI version installed easily using Ubuntu Software Center.

Open Unison and in the default profile give the source location as Root 1 and destination location as Root 2.

Unison default profile

Unison default profile

To automate Unison Backup we’ll create a scheduled task. Open the scheduled tasks app and create a new task. In the command give it like this.
 unison –batch default
Editing a Scheduled Task

Editing a Scheduled Task

Here “default” is the name of the profile you created in Unison.

As I want to do the run the file sync at 10AM every day I have set fields in the advanced section as shown in the image.

Setting up Remote Access

You may need to remotely log into this server using a windows machine. For that you can install xrdp.

sudo apt-get install xrdp 

(You can find more info on this from this article.)

Now open Remote Desktop Connection in the windows machine connected to the same network and give the hostname or the ip of the server machine.

Opening Windows Remote Desktop Connection

Opening Windows Remote Desktop Connection

Here if you find any problem connecting with Sesman-Xvnc module, select console module instead

Remote Desktop Connection

Remote Desktop Connection

 

So now you are almost done! It will be better to clone the drive of Ubuntu installation so you won’t need to do all these things again if ever system crashes. You can use CloneZIlla for that.

Enjoy using SAMBA!