Advertisement

Author Topic: linux.. restore file ..  (Read 5532 times)

0 Members and 1 Guest are viewing this topic.

celi

  • Guest
linux.. restore file ..
« on: January 24, 2012, 09:28:33 AM »
can someone help provide me the command to retrieve a deleted file from root other than doing a restore on  backup or using other utilities?



« Last Edit: January 24, 2012, 11:17:08 AM by mz-HARD »

Like this post: 0

Adverstisement

tetrapod

  • Guest
Re: linux.. restore file ..
« Reply #1 on: January 24, 2012, 08:23:45 PM »
can someone help provide me the command to retrieve a deleted file from root other than doing a restore on  backup or using other utilities?



I don't think there's such a command. 

If you happened to place the file in the trash and didn't empty the trash, you can get it back.




Like this post: 0

celi

  • Guest
Re: linux.. restore file ..
« Reply #2 on: January 25, 2012, 01:12:32 PM »
tetrapod..

i'm looking to see if anyone here can help come up with a shell command (in linux) to retrieve a file that has been removed with rm -i *  other than having to do a restore on the data or by using other utilities.

 



Like this post: 0

tetrapod

  • Guest
Re: linux.. restore file ..
« Reply #3 on: January 25, 2012, 03:53:32 PM »
tetrapod..

i'm looking to see if anyone here can help come up with a shell command (in linux) to retrieve a file that has been removed with rm -i *  other than having to do a restore on the data or by using other utilities.

 

I see.  You have a backup copy of the file?

then just copy the file from the back drive.

for example:

cp /media/backup/myfile/file.txt    /home/myhome/




Like this post: 0

tubyaj

  • Guest
Re: linux.. restore file ..
« Reply #4 on: January 25, 2012, 05:12:02 PM »
Depth of recovery depends on the file system you are using.  Even with ext2 or fat, if the file has been overwritten you may be out of luck.  Obviously, if it's life or death money will probably show you the way. ;D



Like this post: 0

celi

  • Guest
Re: linux.. restore file ..
« Reply #5 on: January 26, 2012, 10:05:54 AM »
@ tetrapod: thx but i wanna recover/retrieve the deleted file w/out having to use the "backup file".

@tubyaj: i understand once you remove <delete> a file in shell command, it's really gone but i'm sure there's a way around to retrieving it back w/out having to physically do a file backup.



Like this post: 0

tetrapod

  • Guest
Re: linux.. restore file ..
« Reply #6 on: January 26, 2012, 10:20:32 AM »
@ tetrapod: thx but i wanna recover/retrieve the deleted file w/out having to use the "backup file".

@tubyaj: i understand once you remove <delete> a file in shell command, it's really gone but i'm sure there's a way around to retrieving it back w/out having to physically do a file backup.


There's no such option.  Maybe there might be third party tools that can do that but a plain linux installation does not have support for recovering a deleted file.  You will have to make a copy from the backup.  That's actually very easy to do. 



Like this post: 0

tubyaj

  • Guest
Re: linux.. restore file ..
« Reply #7 on: January 26, 2012, 11:23:26 AM »
Yeah...like Tetrapod stated, there is no one simple command.  Once you do a rm command it removes the hard link, depending on the file system, and this means the data will eventually get overwritten.  Recovery software just tries to find the bits and pieces and make it whole.  If you have backups just go that route.



Like this post: 0

celi

  • Guest
Re: linux.. restore file ..
« Reply #8 on: January 26, 2012, 01:48:33 PM »
There's no such option.  Maybe there might be third party tools that can do that but a plain linux installation does not have support for recovering a deleted file.  You will have to make a copy from the backup.  That's actually very easy to do. 

lol.. i know and i understand there's no such option but i'm sure there's got to be a way around this... somehow  :-\

remember i say, not with the use of third party tools or having to make backups.  (just hardcore shell commands) :)



Like this post: 0

tetrapod

  • Guest
Re: linux.. restore file ..
« Reply #9 on: January 26, 2012, 08:51:56 PM »
lol.. i know and i understand there's no such option but i'm sure there's got to be a way around this... somehow  :-\

remember i say, not with the use of third party tools or having to make backups.  (just hardcore shell commands) :)

All the time you spent searching for an answer, you could have copy the file from the back drive over hundreds of time.  :)



Like this post: 0

celi

  • Guest
Re: linux.. restore file ..
« Reply #10 on: January 27, 2012, 09:25:46 AM »
All the time you spent searching for an answer, you could have copy the file from the back drive over hundreds of time.  :)


lol.. i had to restore it from my bkup copy some minutes later..but it would be so much convenience if it was just a shell command away...
you guys are pretty smart, i'm sure one of u will find a way to go around this.. and if you guys do. pls share ur knowledge ok  :-*



Like this post: 0

tetrapod

  • Guest
Re: linux.. restore file ..
« Reply #11 on: January 27, 2012, 11:45:05 AM »
lol.. i had to restore it from my bkup copy some minutes later..but it would be so much convenience if it was just a shell command away...
you guys are pretty smart, i'm sure one of u will find a way to go around this.. and if you guys do. pls share ur knowledge ok  :-*

in that case, it makes more sense to write a wrapper for rm that puts the file in a .deleted folder.  In the .deleted folder, there is a file that contains the original path of the file, and the to be deleted file.  User can restore by rm -restore /home/myhome/myfile.txt and it will move the file from .delete to /home/myhome/myfile.txt.  You then have a crone job that delete very old files from your .deleted folder at the end of every week.  There is really no other better option I can think off. 



Like this post: 0

tubyaj

  • Guest
Re: linux.. restore file ..
« Reply #12 on: January 30, 2012, 12:02:31 PM »
In short, move over to Gates domain. ;D

in that case, it makes more sense to write a wrapper for rm that puts the file in a .deleted folder.  In the .deleted folder, there is a file that contains the original path of the file, and the to be deleted file.  User can restore by rm -restore /home/myhome/myfile.txt and it will move the file from .delete to /home/myhome/myfile.txt.  You then have a crone job that delete very old files from your .deleted folder at the end of every week.  There is really no other better option I can think off. 



Like this post: 0

tetrapod

  • Guest
Re: linux.. restore file ..
« Reply #13 on: January 30, 2012, 02:22:42 PM »
In short, move over to Gates domain. ;D


What's that?



Like this post: 0

celi

  • Guest
Re: linux.. restore file ..
« Reply #14 on: February 07, 2012, 04:43:09 PM »
There is no shell cmd to recover.  All recovery programs do a search for file headers and attempt to restore.

-- so after several weeks of pondering... I have figured out how to recover a deleted file on linux by just using command lines.
i thought about writing a perl script to excute it from linux but that was too much work.

anyhow, good news..

lsof is a Linux tool which can show open files and network connections, and even recover deleted files!!!!
more  info on lsof >>>  http://www.catonmat.net/blog/unix-utilities-lsof
http://linux.about.com/library/cmd/blcmdl8_lsof.htm

1) $ lsof | grep datafile.txt
this will output something like ....xxxx 32140 servername 56w xxx ##,# #### / log folder/datafile.txt (deleted)

the32140 is the process that still has the file open and without this process keeping the file open, then the file is lost permanently, hence the process id 32140 and finally look for the file descriptor (fd) which is the 56 (of course this will be different)

Also the idea is to look for the word "deleted"

2) $ cat /dev/32140/fd/56
this outputs the contents of the deleted datafile.txt, which the data is still there so all you need is to redirect the contents back to your directory/original file like this:

3) $ cat /dev/32140/fd/56 > /datalogs/datafile.txt

and whoola.. you have just recovered your datafile.txt with all the data back to its original location.


« Last Edit: February 07, 2012, 04:56:45 PM by mz-HARD »

Like this post: 0

 

Advertisements