Restore accidentally deleted files under CentOS6.x

Source: Internet
Author: User

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

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.