Projekt

Allgemein

Profil

Config samba-trash » Historie » Version 1

Jeremias Keihsler, 13.01.2017 11:37

1 1 Jeremias Keihsler
h1. Configure samba-trash
2
3
h2. Requirements
4
5
To install samba you will need the following:
6
* a installed and supported operating system (e.g. CentOS 6.x)
7
* root-access
8
* a fast internet connection
9
10
h2. Preliminary Note
11
12
this is based on http://www.redhat.com/advice/tips/sambatrash.html
13
14
I’ve found a couple of tutorials on Samba, but neither one had all the right information. After fighting with it a bit, this is what I did to get it working.
15
16
Normally a file deleted by a user on a Samba share is deleted permanently. Did you know that Samba has the ability to move deleted items on a Samba share to a designated recycle folder similar to the way files are deleted on your local machine? We'll show you how and why you may want to do this in this month's Tips and Tricks: "Samba Trash"
17
18
*Can I have a trash/recycle folder in Samba like I have on my desktop?*
19
20
Yes. Samba has the ability to move deleted items on a Samba share to a designated recycle folder similar to the way files are deleted on your local machine. This is an advantage over the standard Samba configuration because normally if a file is deleted by a user on a Samba share it is deleted permanently. One obvious disadvantage is that this will increase the amount of disk space required on the Samba server because you are retaining deleted files. To overcome this you will need to regularly 'clean up' the recycle folders.
21
22
To implement the network recycle folder Samba uses a Virtual File System (VFS) module. The various VFS modules that Samba can use are in the local directory: //usr/lib/samba/vfs
23
24
Documentation on the options for the recycle.so module and other VFS modules can be found in the local directory //usr/share/doc/samba-x.x/docs/Samba-HOWTO-collection.pdf under chapter 19 or on the following website: http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/VFS.html
25
26
h2. Setup 
27
28
<pre><code class="bash">
29
vim /etc/samba/smb.conf
30
</code></pre>
31
<pre>
32
#====================== Share Definitions ========================
33
[root]
34
  path = /mnt/SAMBA
35
  writeable = yes
36
  browseable = yes
37
  read only = No
38
  guest ok = Yes
39
  public = Yes
40
  valid users = jke
41
  create mask = 0666
42
  directory mask = 0777
43
44
  vfs object = recycle
45
    recycle:repository = .deleted/%U
46
    recycle:keeptree = Yes
47
    recycle:touch = Yes
48
    recycle:versions = Yes
49
    recycle:maxsixe = 0
50
    recycle:exclude = *.tmp
51
    recycle:exclude_dir = /tmp
52
    recycle:noversions = *.bak
53
</pre>
54
55
This configuration only implements a recycle folder on the directory "Samba Share". The above options must be specified for each Samba share you want the recycle folder functionality on.
56
57
The most interesting option above is:
58
@recycle:repository = .deleted/%U@
59
60
This specifies where the deleted files will be stored. This is relative to the share path. From the above example "Samba Share" has the path @/home/scripts@. Therefore anything that is deleted is moved to the directory .deleted under this path. The @%U@ variable is the username of the person currently browsing the share. So for every user that deletes a file there is a directory with their username containing all the files they have deleted.
61
62
For example:
63
Scott is browsing the "Samba Share" directory and deletes a file. The deleted file can now be found under @/home/scripts/.deleted/Scott@
64
Brad is browsing the "Samba Share" directory and deletes a file. The deleted file can now be found under @/home/scripts/.deleted/Brad@
65
66
It is important to note that the .deleted directory must be created prior to use.**((as of CentOS 6.3 this is not necessary, the directory is created automagically)) It must then allow users to write to that directory. This is just an example and can be setup differently to suit your particular situation.
67
68
For more tips and/or tricks check out the Red Hat Knowledgebase at: http://kbase.redhat.com
69
70
h2. Test 
71
72
* create a file on the samba-share
73
* delete the file
74
* check if the file has been moved to @.deleted@-directory
75
* delete the file from @.deleted@
76
* check if the file has gone permanently