Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

[ Linux  ] how to configure recycle bin like feature in Linux

Posted on 2014-01-29
8
Medium Priority
?
947 Views
Last Modified: 2014-02-15
OS : Linux

if there any file accidentally deleted we want it to preserve in some location, so that we can recover file incase required.
In other words, this is almost the same feature like in windows -recycleBin

please advise the steps to configure if this possible in windows

Thanks for your support -
0
Comment
Question by:mac_g
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 9

Expert Comment

by:jeff_01
ID: 39817546
It depends how you delete the file.

If you deleted it using the rm command then you would need software recovery tools to recover the file.

Some desktop environments like Gnome, KDE etc will have a similar version of windows recycle bin called Trash. If you delete a file from in the GUI then it should be available in Trash.  There are some scripts available on the web that simulate the function of "Trash" or Recycle Bin, so when deleting a file you use the script instead of rm.  Also there's a library called libtrash that will intercept delete commands and shift the files to a trash directory. Information on it can be found below. Ive never used it myself though.

ftp://hpux.connect.org.uk/hpux/Development/Libraries/libtrash-0.2/libtrash-0.2.README.html
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 39817552
Here is something to look at as well. It will make the rm command move the file to a trash location instead.

http://www.webupd8.org/2010/02/make-rm-move-files-to-trash-instead-of.html
0
 
LVL 13

Expert Comment

by:Daniel Helgenberger
ID: 39817563
Hello mac_g,

can you please elaborate more? I suppose you want this on a Linux samba / nfs file server? You have the recycle bin on every major desktop environment in linux (like gnome, kde...).

That said, you have the major problem / solution here: Recycle Bins are a client side implementation, eg. from your Desktop Environment. You can even have this in the shell by aliasing the rm command.

If you want to have this server side, is no such thing to my knowledge. The only way to achieve this are backups.
The best way would be to use file system events ('in_delete') for that. Though there is incrond, the lack of recursive operations would limit this to a special folder only.

There is one way I consider relatively elegant for a few scenarios: File system snapshots.

You could use for instance LVM in a cron script to make a FS snapshot cycle. Mount this and make a read only share. You can rotate snapshots to your liking.

Keep in mind the thing I said above about a few scenarios. LVM snaps are relatively slow and eat up a lot of the IOPS of your storage, esp. if you maintain several at one. Further, they are limited to a size defined in the creation process and simply 'die' a painful death if they exceed this size.
Bottom line, LVM snapshots are fine for low duty file servers with few files changed and not many concurrent open files.

You can also use BTRFS which handles and performs much better. The drawback: The filesystem is relatively new. Though I had no problems with it for a few months now I would not use it for a production system yet.

If you like to implement the LVM or BTRFS snapshot system, I can further assist you.
0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 
LVL 31

Expert Comment

by:farzanj
ID: 39817603
As said above you can alias the rm command, so when you are calling rm, you are really calling another command or a script.

I had implemented a script.  For rm, I aliased to a script which would compress the file and move to a "RecycleBin" directory.  It would also save the location of the original file before moving.

Then undelete or unrm would uncompress it and move it back to its original location by checking the logs file that keeps track of all the files in the recycle bin.
0
 
LVL 62

Expert Comment

by:gheist
ID: 39826254
alias rm 'mv $* "~/Recycle Bin"'
0
 
LVL 13

Accepted Solution

by:
Daniel Helgenberger earned 1500 total points
ID: 39827072
To add a somewhat imported thing to the above comment: You need to create a '~/Recycle Bin' directory first and always make shure it exists. Otherwise your last deleted file would be moved to a file called 'Recycle bin' overwriting the previously deleted file.
Also it is somewhat inefficient when deleting files on other file systems then / or
/home respectively.
I suggest wiring a script witch takes care of the above cases.
(Pardon me, when using the shell I cannot imagine cases I would need such a thing as a recycle bin)
0
 
LVL 25

Expert Comment

by:madunix
ID: 39849914
It is very difficult to recover the data from deleted filesystem in linux, there is not  a direct way to restore deleted files, you need to use 3rd party tool.


Is there a way to automatically recover the files in "/lost+found" directory?
https://access.redhat.com/site/solutions/36632

How to recover a deleted file in ext3 filesystem?
https://access.redhat.com/site/solutions/24862

How to recover a deleted file on ext2 file system?
https://access.redhat.com/site/node/2214

How do I backup and restore a whole Red Hat Enterprise Linux system with the dump/restore commands?
https://access.redhat.com/site/solutions/17525
0
 

Author Closing Comment

by:mac_g
ID: 39862336
while defining alias ..

what about the options like  ...-rf  while we define alias..
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question