How to recover a CentOS mistakenly deleted file

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.