Solved

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

Posted on 2014-01-29
8
835 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
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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 61

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now