7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

How to recover deleted files?

Thu Jul 17, 2014 5:14 pm

So, I went and rm -rf'ed a folder, with files I need inside of it.

Is it possible to get it back with file recovery programs or anything like that? Yes, I know I should've had a back up...

Is there a cached folder, or something... anything?

Any recommendations apart from backing up next time?
Raspberry Pi - Model B (512MB)

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: How to recover deleted files?

Thu Jul 17, 2014 5:26 pm

If it's on a hard disk you can make a low level copy of the disk with dd then inspect the img and hope nothing wrote over the files yet.
I'm not sure if flash media complicates that.

More reading:
https://www.google.com/search?hl=en&q=l ... 20recovery
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

User avatar
joan
Posts: 14847
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to recover deleted files?

Thu Jul 17, 2014 5:28 pm

There are programs which attempt to recover deleted Linux files. Google should find them.

I do know you are meant to shut down the file system as soon as possible so that the files aren't overwritten with new data.

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How to recover deleted files?

Thu Jul 17, 2014 6:05 pm

elatllat wrote:If it's on a hard disk you can make a low level copy of the disk with dd then inspect the img and hope nothing wrote over the files yet.
I'm not sure if flash media complicates that.

More reading:
https://www.google.com/search?hl=en&q=l ... 20recovery
I have the SD card in my PC now, one recovery program found the folder, but no files... :(
Raspberry Pi - Model B (512MB)

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How to recover deleted files?

Thu Jul 17, 2014 6:06 pm

joan wrote:There are programs which attempt to recover deleted Linux files. Google should find them.

I do know you are meant to shut down the file system as soon as possible so that the files aren't overwritten with new data.
I did shut it down, and am scanning the SD with PhotoRec now, but it's also finished and hasn't found the filetype I'm looking for :(
Raspberry Pi - Model B (512MB)

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: How to recover deleted files?

Thu Jul 17, 2014 6:25 pm

I have the SD card in my PC now, one recovery program found the folder, but no files... :(
What kind of files have you deleted i.e. jpg, mp3, python scipts etc??

Richard S.

7ewis
Posts: 130
Joined: Wed Dec 26, 2012 11:30 am

Re: How to recover deleted files?

Thu Jul 17, 2014 11:32 pm

I was trying to recover some Python scripts.

Came up with some .py diles , but they were full of writing that didn't makes sense... And wasn't Python.
Raspberry Pi - Model B (512MB)

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: How to recover deleted files?

Sat Jul 19, 2014 12:04 am

You can dump the whole sdcard as text and then just search for a part of your python script (not the filename).

Code: Select all

cat sdcard_dump.img | perl -pe 's/[^A-Za-z0-9 \/\?\>\<\.\,\'\;\"\:\\\|\]\[\}\{\=\-\+\_\`\~\!\@\#\$\%\^\&\*\(\)\n\t]+/\n/g' > search_me.txt
(I'm sure there is a less ugly regex but that should work)
If the file is to big to open you can scan it like so:

Code: Select all

grep -A 10 -B 10 whatever search_me.txt | more
You might only get parts of the file but if it's not in there it's not retrievable.


If you use git backing up can be fun and automatic (I know you don't want to hear backup next time but git is the best thing since ... anyway rdiff-backup and rsync are good for other things)
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

Return to “General discussion”