Solved

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

Posted on 2014-01-29
8
888 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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 500 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

751 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