Enable VFS and Recycle functionality in Samba

Posted on Friday, 30 of December of 2016
1245by Octávio GonçalveslinuxSamba

A major problem in business is data loss.
In a distributed document sharing within a company, the system always run the risk, by user error losing important data in seconds.

So, assuming that we have implemented in our company SAMBA for distribution and sharing of documents between users, we can circumvent this problem by enabling "recycle" functionality in Samba.

Note, that this solution does not void a good backup system and infrastructure. This solution is perfect to recover one or more deleted files, saving time, so you don't need to use the backups service.

To do this, we must apply the following steps:

1. Installing VFS (Virtual File System), the SAMBA:

sudo apt-get install samba-vfs

OR
In newest Ubuntu versions (Ubuntu 14.04 or Higher):

sudo apt-get install samba-vfs-modules

(Most modern distributions come with pre-installed this module, but if yours does not you can install it.)

2. Smb.conf - Open the file in your favorite editor, mine is VIM.

sudo vim / etc / samba / smb.conf

3. If you want to enablerecycle functionality

in global module, add the following lines to the [general] section. For individual shares add the following lines to the [share name] section. You need to change the recycle: repository setting to a directory on your file system. Do not change the% U at the end the this is used to substitute the file name.

# Enable the recycle binvfs object = recyclerecycle: repository = / myfolder / recycle /% Urecycle: touch = Yesrecycle: keeptree = Yesrecycle: versions = Yesrecycle: noversions = * tmp, * temp, * o, * obj, * TMP, TEMP *......recycle: exclude = * tmp, * temp, * o, * obj, * TMP, TEMP *......recycle: excludedir = / recycle, / tmp, / tmp, / tmp, / TEMP

4. In this example I have added the lines to the Pictures share.

[Pictures]guest account = rootforce user = rootwriteable = yesdelete readonly = yespublic = yespath = / myfolder / pictures# Enable the recycle binvfs object = recyclerecycle: repository = / myfolder / recycle /% Urecycle: touch = Yesrecycle: keeptree = Yesrecycle: versions = Yesrecycle: noversions = * tmp, * temp, * o, * obj, * TMP, TEMP *......recycle: exclude = * tmp, * temp, * o, * obj, * TMP, TEMP *......recycle: excludedir = / recycle, / tmp, / tmp, / tmp, / TEMP

Restart Samba with the command sudo service smbd restart and delete the test file to verify it works.

Share or save this article

slashdot