LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-05-2010, 11:01 AM   #1
BrinkofMadness
LQ Newbie
 
Registered: Dec 2010
Posts: 6

Rep: Reputation: 0
Unhappy how do i write a bash script to restore deleted files to original location?


Hi
I have managed to write a bash script that moves files to the recylce bin instead of being deleted. Then (with a bit of assistance) wrote another bash script that deletes the files from the recycle bin. Now I need to write one that will restore the files preferably to their original location? I am very new to linux and stuggling with where to even begin...any ideas? There seems to be some advice about creating a cloning tree, but I've never heard of them? Would much appreciate a little pointer to get me started.
 
Old 12-05-2010, 11:09 AM   #2
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
So do you want to restore them before or after they've been removed from the recycle bin?
 
Old 12-05-2010, 11:38 AM   #3
BrinkofMadness
LQ Newbie
 
Registered: Dec 2010
Posts: 6

Original Poster
Rep: Reputation: 0
After they have been deleted. Is it even possible? Thanks
 
Old 12-05-2010, 11:50 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by BrinkofMadness View Post
I have managed to write a bash script that moves files to the recylce bin instead of being deleted.
You should have stayed with your original thread here: http://www.linuxquestions.org/questi...orking-848364/ or at least added a link so people know what you're talking about.


Quote:
Originally Posted by BrinkofMadness View Post
Now I need to write one that will restore the files preferably to their original location?
Your initial problem would be explaining what process moves files to ~/dustbin/. If you can't then I wonder why you too consider a kludge over using libtrash? (Also see: http://www.linuxquestions.org/questi...9/#post3987860, http://www.linuxquestions.org/questi...s-root-705779/).
 
Old 12-05-2010, 11:54 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by BrinkofMadness View Post
After they have been deleted. Is it even possible?
No, not easily and not consistently. Maybe check freshmeat.net for Back In Time, Flyback and TimeVault for rsync-based restoration, bypassing any need for a trashcan kludge.
 
Old 12-05-2010, 12:30 PM   #6
BrinkofMadness
LQ Newbie
 
Registered: Dec 2010
Posts: 6

Original Poster
Rep: Reputation: 0
After they have been deleted? Is it even possible; maybe with lsof and grep? I'm just thinking of possible ways to manage it. Not getting very far unfortunately.
 
Old 12-05-2010, 02:01 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by BrinkofMadness View Post
After they have been deleted?
No, not easily and not consistently.


Quote:
Originally Posted by BrinkofMadness View Post
Is it even possible; maybe with lsof and grep?
You're trying to do the right thing the wrong way and that actually started with your other thread.
You don't want a "dustbin" nor a kludge to manage it: you want either libtrash or (rsync-based) backups.
 
Old 12-05-2010, 03:02 PM   #8
BrinkofMadness
LQ Newbie
 
Registered: Dec 2010
Posts: 6

Original Poster
Rep: Reputation: 0
At present I have scripts that
1. move files to the dustbin
2. empty the dustbin

is it possible then maybe to store the file elsewhere, maybe in a temp file, as well as moving it to dustin and then I could restore from there? Sorry about not starting a new thread and not adding to my old one and thanks for putting on the link :-)
 
Old 12-05-2010, 07:04 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
You can create as many copies as you want, wherever you want, but once you physically delete a (copy of) a file, that copy is gone. It's very hard & unreliable to attempt to recover them. Use backups instead.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Nautilus Trash Information Plugin: Date Deleted And Original Location LXer Syndicated Linux News 0 04-01-2010 11:50 PM
[SOLVED] my bash file is deleted , trying to restore from kernel arguments miteshpant Linux - Newbie 9 09-25-2009 01:19 PM
Restore deleted files Winanjaya Linux - Newbie 5 01-09-2007 02:23 AM
how to restore deleted files? ice99 Linux - Security 13 04-13-2006 04:10 AM
how to restore deleted files ? ilyes Linux - General 3 08-01-2003 08:13 AM


All times are GMT -5. The time now is 09:27 AM.

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