Restore accidentally deleted files under CentOS6.x
When you realize that a file is accidentally deleted, do not write the file frequently. Otherwise, your data recovery volume will be small. What we need to do is to immediately stop all the services on the server and directly killall the process name or kill-9 pid. Then, mount the partition where the file is accidentally deleted and remount it to ro, read-only (mount-o ro/dev/sdb2/data /).
Then we need to download and install a tool called extundelete.
1. Install the dependency package
# Yum install e2fsprogs *-y
2. Download and install extundelete
# Wgethttp: // nchc.dl.sourceforge.net/p... elete-0.2.4.tar.bz2
# Tar-jxvf extundelete-0.2.4.tar.bz2
# Cd extundelete-0.2.4
#./Configure -- prefix =/usr/local/extundelete
# Make & make install
3. verify whether the installation is successful
# Cd/usr/local/extundelete/bin
#./Extundelete-v
---------------------
Extundelete version 0.2.4
Libext2fs version 1.41.12
Processor is little endian.
---------------------
If we accidentally delete the partition where the file is located:/dev/sdb2
The recovery procedure is as follows:
/Usr/local/extundelete/bin/extundelete/dev/sdb2 -- inode 2 // scan which files are deleted
Assume that a file named 1.txt has been deleted. The command to restore it is:
/Usr/local/extundelete/bin/extundelete -- restore-file 1.txt/ dev/sdb2
RECOVERED_FILES/directory of the recovered file in the current directory
Ls./RECOVERED_FILES/You can see 1.txt
To restore files in the entire partition, you can:
/Usr/local/extundelete/bin/extundelete -- restore-all/dev/sdb2
The recovered files are also under./RECOVERED_FILES/. It depends on your luck.
Of course there will be:
1. Remount the partition to writable
2. Back up important data
3. overwrite the recovered data
4. Restart the server and restore various services.
This article is from the "Debris memory" blog, please be sure to keep this source http://debris.blog.51cto.com/1614432/1623966