When you are aware of the accidental deletion of files, you should never write more frequently, otherwise your data recovery will be very small. And what we want to do is, the first time the service on the server all stop, directly killall process name or kill-9 PID. Then delete the deleted files from the partition, re-mount the RO, read-only (Mount-o ro/dev/sdb2/data/).
Then we need to download and install a tool called Extundelete
1. Installing dependent Packages # yum Install e2fsprogs*-y
2. Download and install Extundelete # wget http://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 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. ---------------------
If we mistakenly delete the file where the partition is/DEV/SDB2 The recovery steps are as follows:
/USR/LOCAL/EXTUNDELETE/BIN/EXTUNDELETE/DEV/SDB2--inode 2//can scan which files have been deleted
If we have a file called 1.txt was deleted. Then the command to restore it is:
/usr/local/extundelete/bin/extundelete--restore-file 1.TXT/DEV/SDB2
The recovered_files/directory of the recovered files in the current directory ls./recovered_files/can be seen with 1.txt
And you want to recover the files on the entire partition like this: /usr/local/extundelete/bin/extundelete--RESTORE-ALL/DEV/SDB2
The recovered files are also under the./recovered_files/, can be restored depends on your luck good.
Of course, follow-up work is also: 1. Re-mount the partition as writable 2. Back up important data 3. Overwrite the data we recovered 4. Restart the server to restore various services |
How to recover a CentOS mistakenly deleted file