dlandon

Recycle Bin (vfs recycle) for 6.3 and later versions

Recommended Posts

This pugin will only work with unRAID V6.3 and later versions.

 

This is a plugin that will create a per share .Recycle.Bin folder on each smb share for files deleted on that share.  Built into samba is a module called "vfs recycle" that handles the deletion of files.  This plugin manages the vfs recycle settings using smb-shares.conf and starts and stops vfs recycle.  Basically samba is restarted with the smb-shares.conf file configured for vfs recycle.

 

The reason the folder name of .Recycle.Bin was chosen is so the recycle bin is a hidden folder.  This is the normal way a recycle bin works.

 

The way vfs recycle works when a file is deleted is to move the file pointers (directory information) to the .Recycle.Bin folder on the same share where the file is located.  Each share will have its own .Recycle.Bin folder where the files deleted from that share are located.  The .Recycle.Bin folder is created when a file on that share is deleted.

 

A .Recycled.Bin folder per share is created and contains all deleted files for that share.  This deleted file organization can be modified in the webgui.  You can set parameters to organize deleted files by user or machine and then the file structure after that.  The deleted files can then be recovered as necessary by browsing to //Tower/share/.Recycle.Bin. 

 

You can also optionally set up a weekly empty trash event that will delete files older than a configurable number of days.  Deleted files are dated when they are deleted and not their original date.  You can click on a "Remove Aged Files" button on the webgui and deleted files will be removed based on the aged days setting.

 

You can make the .Recycle.Bin folder visible in the shares by setting 'Hide "dot" files' to no in the smb settings.  You can then browse the .Recycle.Bin folders.  If the folder is not visible, you can browse to it by using //Tower/share/.Recycle.Bin.

 

I recommend setting up the weekly cron and set the age days to something that makes sense for you (default is 7 days).  That will keep the .Recycle.Bin folder from getting out of hand.

 

Note: Shares will not show up when browsing the Recycle Bin from the webGui unless there is a .Recycle.Bin folder on that share.

 

Click on the 'Help' button on the upper right of the menu bar and you will get explanations of the settings.

 

The preferred way to install the plugin is using Community Applications or you can cut and paste this link into the "Install Plugin" line to install the plugin:

https://github.com/dlandon/recycle.bin/raw/master/recycle.bin.plg
 
If you need the older version for 6.1 or 6.2 versions of unRAID, you can manually install it using this url.  Cut and then paste this into the "Install Plugin" line to install the previous version of the plugin:
https://github.com/dlandon/recycle.bin/raw/master/recycle.bin.6.1.plg
 
Note: Be sure to remove any older plugin (prior to V6.3) before installing this new version.

 

Note: If you remove the plugin, the .Recycle.Bin share folders will not be emptied.  If you want to permanently remove the plugin, you need to empty the trash before removing the plugin.

 

Excluding Shares

 

Enter the share names to exclude from the recycle bin.  You can treat these names as wild cards.  Any share that has the text that is in the excluded share will be removed, unless single quoted.  If the share name is single quoted, the share must match exactly to be excluded.

Example:

Shares:

Joe Files

Sam Files

Files

 

Setting exclude to Files will exclude all three shares.  Setting exclude to 'Files' will exclude only the Files share.

 

Credits: This plugin is based on the previous work of Influencer done back in the V5 days.

Edited by dlandon
  • Upvote 3

Share this post


Link to post
Share on other sites

The RecycleBin is a hidden share because it's name is .Recycle.Bin.  It can be seen in the unRAID shares when browsing from a Windows computer, but is not listed in the unRAID shares.  I believe the mover skips dot files when moving files from the cache drive to the array.  I'm not sure I like this for several reasons:

- It uses the cache drive and it looks like files aren't moving off the cache drive.  I see some files on disk1.

- I would think it would be best to control the share visibility, access, etc if it was a visible share and share parameters could be modified from the webgui.  For example, it might be best to make it a hidden share from the webgui.

- I'm not sure how the files are allocated.  I think it's the default high water, which would tend to always go to the first disk until it reaches the high water mark.

 

I'm really thinking that it should just be named RecycleBin without the dots.  Does anyone recall why the decision was made to make the name .Recycle.Bin so the share would be hidden?

 

I'd like to get some ideas here before I make any drastic changes, but I'm inclined to change the name and remove the dots.

 

EDIT: After doing some research it makes sense for the recycle bin to be a hidden folder.  More explanation in the OP.

Share this post


Link to post
Share on other sites

In my older version of the plg - I removed the . so it was not .Recycble.bin and prefer it that way

 

Myk

 

Share this post


Link to post
Share on other sites

In my older version of the plg - I removed the . so it was not .Recycble.bin and prefer it that way

 

Myk

 

So you use Recycle.Bin?

Share this post


Link to post
Share on other sites

Not sure you noticed the recent change to the behavior of the mover script.

 

The default setting for a user share is Use cache disk: NO. And mover will not move a share unless it is Use cache disk: YES. This is a recent change to the mover script to help with the (surprise!) issue of people specifying apps to use /mnt/cache/something and then having mover move it to the array. The way it worked prior to this change is mover skipped cache-only shares, now it only moves cache-yes shares.

 

Just started exercising this plugin a little to see what it does.

 

Looking at the new config/smb-extra.conf entries the plugin made, it doesn't mention cache, just /mnt/user, so the cache drive should not be involved since the share isn't configured to Use cache disk: Yes or Only.

 

I deleted a file from one of my user shares. I got new paths on 2 of my disks (not cache), and the deleted file is in one of them. Not sure why it would have created the path on 2 disks.

 

I don't think it should be necessary to have the folder hidden. Even if the user configures the Recycle Bin share to Use cache disk: Yes or Only seems like it should still work as intended. Not sure what the purpose of hiding the folder was originally. If it was for hiding it from mover, it's not obvious to me why that would be a good thing.

Share this post


Link to post
Share on other sites

In my older version of the plg - I removed the . so it was not .Recycble.bin and prefer it that way

 

Myk

 

So you use Recycle.Bin?

 

Yes

 

I also remember it moving the deleted file on diskX to Recycble.Bin on that same diskX drive....

 

Previous - unRAID never managed the Recycle.Bin folder and you could not delete it, just its contents.  You disabled it, and then Recycle.Bin would be removed.

 

Myk

Share this post


Link to post
Share on other sites

In my older version of the plg - I removed the . so it was not .Recycble.bin and prefer it that way

 

Myk

 

So you use Recycle.Bin?

 

Yes

 

I also remember it moving the deleted file on diskX to Recycble.Bin on that same diskX drive....

 

Myk

My deleted file did get moved to the same drive it was on. Probably that is just the way shfs makes it happen if the Recycle.Bin share can be on the same disk.

 

Don't know why it also created a path on another disk, maybe something else about the way shfs works.

Share this post


Link to post
Share on other sites

Yes, from what I have experienced the deleted file remains on the same drive but moved into the Recycle directory you have setup.

Share this post


Link to post
Share on other sites

The path that got created but not used was on disk1, so maybe it was just trying to create a folder for the share, but then when it did the move, it moved it to the disk it was on, which also created the path. In any case, I expect some of these details are not under the control of the plugin, but instead is just the way SMB and shfs are handling things.

Share this post


Link to post
Share on other sites

Noticed a typo, I assume from this plugin, when starting the array. The message that shows at the bottom of the webui as part of the starting messages says "Startinig Recycle Bin"

Share this post


Link to post
Share on other sites

Noticed a typo, I assume from this plugin, when starting the array. The message that shows at the bottom of the webui as part of the starting messages says "Startinig Recycle Bin"

 

Dang I hate that!  I'll take care of it.  My OCD would never let that pass.

Share this post


Link to post
Share on other sites

Yes, from what I have experienced the deleted file remains on the same drive but moved into the Recycle directory you have setup.

 

Now that makes a lot of sense and is what I have seen.  I guess the .Recycle.Bin on the cache is because that's where the file was located.

 

I have done some reading and it seems vfs recycle does create the recycle directory on the disk the file was deleted from.  The really cool thing on unRAID is that the RecycleBin share shows all the files regardless of the disk they are on.

Share this post


Link to post
Share on other sites

The path that got created but not used was on disk1, so maybe it was just trying to create a folder for the share, but then when it did the move, it moved it to the disk it was on, which also created the path. In any case, I expect some of these details are not under the control of the plugin, but instead is just the way SMB and shfs are handling things.

 

One of my initial concerns was that the cache was going to get loaded with deleted files and nothing would be moved off because of the .Recycled.Bin directory having a leading dot.

 

Now that I understand a little better, I'm inclined to leave things alone for now.

 

I undertook this project to update the plugin without fully understanding the vfs recycle functionality in samba.  Now that I understand it a little better, I like it even more.  With the vfs recycle being baked into samba in unRAID already, I'd like to think LT would eventually consider this as core functionality.  This plugin is not much more that a webgui for the vfs recycle, much like the apcupsd plugin that was eventually included in the core.

Share this post


Link to post
Share on other sites

I appreciate the effort you undertook to get this plugin updated for the 6.1 series.

 

I too feel that @limetech should include this functionality natively in core unRAID. It would be a really nice set of features added with bit marketing potential and low level of work required to do so.

Share this post


Link to post
Share on other sites

I appreciate the effort you undertook to get this plugin updated for the 6.1 series.

 

I too feel that @limetech should include this functionality natively in core unRAID. It would be a really nice set of features added with bit marketing potential and low level of work required to do so.

 

You're welcome.  This one was kind of fun.  I did have a bit of an issue with php and the new webgui methods.  bonienl helped me and I got over the last hurdle.

Share this post


Link to post
Share on other sites

Installed fine as an update.  The RecycleBin folder didn't show anything when I accessed via Explorer after deleting a files or 2.  In the plugin settings it said it had 20kb which was a few test files I was deleting so they were there, just not visable.  I had to manually change permissions for for that folder and they magically appeared.

 

My Windows 10 laptop however can't access the RecycleBin folder at all.  Looks like it trying to connect as a domain instead of the Workgroup its set to.  :(  All other shares are accessible, and I can access it perfectly fine with my Windows 7 machine.  Grrr.  My feeling is that this is a Windows 10 issue, good old MS.

 

I noticed in the extra folder that it's setting permissions to 777, is this working?

 

Great work though dlandon!  Quick work too!  Really appreciated!

Share this post


Link to post
Share on other sites

Installed fine as an update.  The RecycleBin folder didn't show anything when I accessed via Explorer after deleting a files or 2.  In the plugin settings it said it had 20kb which was a few test files I was deleting so they were there, just not visable.  I had to manually change permissions for for that folder and they magically appeared.

 

My Windows 10 laptop however can't access the RecycleBin folder at all.  Looks like it trying to connect as a domain instead of the Workgroup its set to.  :(  All other shares are accessible, and I can access it perfectly fine with my Windows 7 machine.  Grrr.  My feeling is that this is a Windows 10 issue, good old MS.

 

I noticed in the extra folder that it's setting permissions to 777, is this working?

 

Great work though dlandon!  Quick work too!  Really appreciated!

 

I can browse the recycle folder with all my Windows 10 computers and a Windows 7 VM.  What permissions did you change and what did you change them to?

Share this post


Link to post
Share on other sites

Installed fine as an update.

 

Update from the older plugin?  That won't work.  The old plugin did not clean up well after itself and there will be a lot of stuff left over that can interfere with the new plugin.

 

You would need to completely remove the old plugin and possibly manually remove all the old .Recycle.Bin directories from each drive and cache drive - although I think these would go away once they are empty and you do a reboot.  Be sure that the smb-extra.conf file is deleted from /boot/config.  Remove all remnants of the old plugin from your flash drive.

Share this post


Link to post
Share on other sites

make sure not to completely remove the smb-extra if you are using unassigned devices plugin - there are includes in there for it

 

Myk

 

Share this post


Link to post
Share on other sites

would prefer a include in the smb-extra file for recycle bin stuff - old plugin did this and the new one does as well

 

include = /etc/samba/unassigned-shares/appdisk.conf
include = /etc/samba/unassigned-shares/appdisk2.conf#vfs_recycle_start

 

note the end of the 2nd include line...

 

Myk

 

Share this post


Link to post
Share on other sites

My Windows 10 laptop however can't access the RecycleBin folder at all. 

 

I had the same issue on Windows 7 until I actually deleted something.  Once there was something in the recycle bin share I was able to access it over the network without a problem.

 

update - now I see you said you did delete something.  Sorry, guess I responded too fast.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.