Wednesday, 14 August 2013

Centos 6/RHEL set up a network recycle bin for Samba

A network does not have a recycle bin and the action of deleting a file from a shared folder on your network will result in the permanent loss of that data. So here we look at creating a holding area for files and folders and enable you to recover data that was accidentally deleted through a simple implementation of Samba's recycling process, CentOS will treat those files in the same way as though you were deleting a file on your desktop.

This assumes that you have Samba installed and set up.

First log in as root and create a folder called recycle-bin in the home directory

# mkdir /home/recycle-bin

Assign the correct permissions to this folder

# chmod 0775 /home/recycle-bin

Open your current samba configuration file by typing

# vi/etc/samba/smb.conf

Scroll down and before the end of the [global] section and the beginning of the
[homes] section, add the following lines

vfs object = recycle
recycle:repository = /home/recycle-bin/%U
recycle:keeptree = Yes
recycle:touch = Yes
recycle:versions = Yes
recycle:maxsize = 0
recycle:exclude = *.tmp
recycle:exclude_dir = /tmp, /recycle-bin
recycle:noversions = *.tmp, *.temp

Finally, at the end of the configuration file add the following lines in order to make the recycle bin available to your network users

[recycle-bin]
path = /home/recycle-bin
public = yes
writable = yes
browsable = yes

Save and close the file before restarting Samba

Service smb restart && service nmb restart