LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-01-2009, 02:29 PM   #1
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Rep: Reputation: 30
Samba Recycle Bin - Tip


Here's a neat tip I've been using for a few years now.

My users have a network share that they use on their XP desktops. However, if they delete files, the files are gone forever.

However, there's a stackable VFS module in Samba called "recycle".

What it basically does, is instead of actually deleting the file, it moves it to another directory that you specify. This allows you to get the file back to them that's as current as the time that they deleted it, rather than from the previous night's backup. (you DO have nightly backups right? )

Anyway, here's my config to help you all out:

SMB.CONF

[Docs]
read only = no
path = /mnt/array/docs
write list = @users
force directory mode = 770
force create mode = 660
valid users = @users
inherit acls = Yes
inherit permissions = Yes
vfs objects = full_audit recycle
config-file = /etc/samba/recycle.conf
recycle:repository = /mnt/recycle/%u
recycle:directory_mode = 770
recycle:keeptree = Yes
recycle:versions = Yes
recycle:touch_mtime = yes
full_auditrefix = %u|%I
full_audit:success = open mkdir rmdir write unlink rename
full_audit:failure = mkdir rmdir write unlink rename


and here's the /etc/samba/recycle.conf file contents:

##Recycle Bin Configuration File##
name = Recycle Bin
mode = KEEP_DIRECTORIES|VERSIONS|TOUCH
maxsize = 0
exclude = *.o|*.obj|~$*|*.~??|*.log|*.trace
excludedir = /mnt/array/misc|/tmp|/temp|/cache
noversions = *.dat|*.ini

Now, for the smb.conf file, most of it should be very familiar or obvious what it does. the recycle:repository is the folder that the files are moved to. The %u specifies the user. So, if user "foo" deletes a file, it'll be put into /mnt/recycle/foo

the "recycle:keeptree" basically means that it'll keep the directory structure intact if a user deletes a folder "very common in my neck of the woods".

Now, the most important thing for me is the next "recycle:touch_mtime" I use this to help prune files. If you don't have a plan on what to do with old files once a certain time frame has passed, say 2 weeks, the recycle folder will fill up rather quickly.

For this, I use a simple cron job:

@daily find /mnt/recycle/* -mtime +30 -exec rm {} \;

This will go through the recycle folder and delete anything older then 30 days. I have users who travel for long periods so, I had to adjust mine to 30 days. Your mileage may vary.

The recycle.conf file has a few things that I wanted to exclude for my own network. It excludes things like Office temporary files, log files, etc.

Since you guys have helped me out a ton, I thought I'd share a neat tip with you all that has saved me a LOT of headaches. The documentation leaves a lot to be desired for an otherwise excellent program!

http://www.samba.org/samba/docs/man/...html#id2644353
 
Old 05-02-2009, 10:54 AM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,978
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Thanks for sharing...

FYI...configuration files are easier to read if you put them in "code" tags...
 
Old 05-02-2009, 11:42 AM   #3
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by custangro View Post
Thanks for sharing...

FYI...configuration files are easier to read if you put them in "code" tags...
Yep, you're right, I forgot about the code tags.
 
Old 09-20-2011, 12:45 AM   #4
AlexanderZubin
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
Samba Recycle Bin - Tip

I found a solution to a recursive .recycle folder creation. Try this

[Global]
vfs object = recycle
recycle:keeptree = yes
recycle:versions = yes
recycle:repository = .recycle
recycle:touch_mtime = yes
recycle:exclude = *.tmp, *.bak
recycle:exclude_dir = .recycle

Exclude_Dir does the trick !!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba and Windows Recycle Bin scottpioso Linux - General 1 05-01-2009 02:29 PM
Recycle bin. patsyking Linux - Newbie 3 12-30-2008 11:27 AM
Recycle Bin scbops Linux - Newbie 6 03-24-2006 06:39 AM
fluxbox recycle bin pingvina Linux - Software 1 01-11-2006 05:25 AM
Recycle Bin? puzz_1 Linux - General 1 05-25-2003 03:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration