LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how do i write a bash script to restore deleted files to original location? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-write-a-bash-script-to-restore-deleted-files-to-original-location-848462/)

BrinkofMadness 12-05-2010 10:01 AM

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.

barriehie 12-05-2010 10:09 AM

So do you want to restore them before or after they've been removed from the recycle bin?

BrinkofMadness 12-05-2010 10:38 AM

After they have been deleted. Is it even possible? Thanks

unSpawn 12-05-2010 10:50 AM

Quote:

Originally Posted by BrinkofMadness (Post 4181286)
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 (Post 4181286)
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/).

unSpawn 12-05-2010 10:54 AM

Quote:

Originally Posted by BrinkofMadness (Post 4181308)
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.

BrinkofMadness 12-05-2010 11:30 AM

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.

unSpawn 12-05-2010 01:01 PM

Quote:

Originally Posted by BrinkofMadness (Post 4181360)
After they have been deleted?

No, not easily and not consistently.


Quote:

Originally Posted by BrinkofMadness (Post 4181360)
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.

BrinkofMadness 12-05-2010 02:02 PM

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 :-)

chrism01 12-05-2010 06:04 PM

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.


All times are GMT -5. The time now is 04:35 PM.