In a CentOS system, when files are deleted by mistake, the following steps are performed to recover the files.
1. Turn off all services
When the deletion of files by mistake, in order to recover the data as much as possible, first to shut down all the services in progress, do not write the data, or the probability of recovery is low. We can directly
# Killall Process Name
Or
# kill-9 PID
And then put the deleted files in the partition, re-mount the read-only
# Mount-o ro/dev/sdb/data/
2. Installing Extundelete Tools
# yum Install-y e2fsprogs*//Install dependency pack
# wget http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-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 that 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.
---------------------
4. Recovering data
Example: If we mistakenly delete the file as Test.txt, the partition is/DEV/SDB.
1) Scan files
#/USR/LOCAL/EXTUNDELETE/BIN/EXTUNDELETE/DEV/SDB--inode 2//scan which files have been deleted
2) Recover files
#/usr/local/extundelete/bin/extundelete--restore-file Test.txt/dev/sdb
3) View Files
The recovered files are in the recovered_files/directory under the current directory
# ls ./recovered_files/
You can see the Test.txt file.
Note :
If you want to recover files on an entire partition, you can execute the following command
#/usr/local/extundelete/bin/extundelete--restore-all/dev/sdb
The recovered files are also under the./recovered_files/directory.
5. Follow-up work
1) re-mount the partition as writable.
2) Back up important data.
3) Overwrite the data we recovered.
4) Restart the server and restore the various services that were shut down before.
This article is from the "M April Days" blog, please be sure to keep this source http://msiyuetian.blog.51cto.com/8637744/1707646
CentOS system recovers deleted files by mistake