Extundelete 数据恢复

Extundelete 数据恢复php

“rm -rf /*” 是咱们常用的命令,操做不慎全盘接蹦,从删库到跑路,身为过来人的咱们都经历过rm带来的痛苦。node

不要慌,当咱们有了Extundelete就能够解决一系列误删除操做问题。下面我会详细介绍一下这款救命工具。mysql

介绍redis

常见的开源恢复工具备:debugfs、R-Linux、ext3grep、extundeletesql

  • ext3grep:只支持 ext3 文件系统
  • extundelete:支持 ext3 和 ext4 文件系统

实现原理:经过分析文件系统日志,解析出全部文件的 inode 信息,利用 inode 去查找所在 block ,利用 dd 备份出以删除的数据。ide


搭建memcached

  • 包名:extundelete-0.2.4.tar.bz2
  • 可靠的下载地址:https://pan.baidu.com/s/1WQ8Ns6_sz9yZmkUGVs7ZyA
  • 更可靠的密码:5c6a

一、安装依赖包工具

yum -y install e2fsprogs-devel gcc

二、解压工具包ui

tar jxf extundelete-0.2.4.tar.bz2

三、指定安装目录、编译、编译安装this

./configure ; make ; make install

使用

经常使用参数:

--after dtime            时间参数,表示在某段时间以后被删除的文件或目录
--before dtime           时间参数,表示在某段时间以前被删除的文件或目录
--inode ino              显示节点 ino 的信息
--block blk              显示数据块 blk 的信息
--restore-inode ino      表示恢复节点 ino 的文件,用来恢复单个文件
--restore-file path      表示恢复指定路径下的文件,用来恢复目录下全部文件
--restore-all            表示恢复全部被删除的目录跟文件     

开启恢复流程:

一、查找被删除文件所在目录 id

ls -id /xxx/xxx/

注:输出最左侧为ID号。

二、查看被删除的上层目录 inode

# extundelete 所在分区名称 --inode ID号
extundelete /dev/sdb1 --inode 130619
# 能够看到被删除的目录 package 状态为 Deleted ,inode 为 137256
File name | Inode number | Deleted status
.                 130619
..                130587
package           137256   Deleted
apr-1.5.1         140038
apr-util-1.5.4    535002
httpd-2.4.10      535320
pcre-8.30         656184
siege-3.0.8       656483
libmcrypt-2.5.8   144383
package.xml       146709
mysql-5.6.4-m7    140588
memcache-2.2.7    146712
php-5.4.13        667097
redis-2.2.5       269016
memcached-1.4.15  146806
libevent-master   539531   Deleted
输出案例

三、恢复数据、恢复指定目录下全部删除的数据

# extundelete 数据所在分区名称 --restore-directory 恢复数据的目录
extundelete /dev/sdb1 --restore-directory /xxx/xxx/xxx/
NOTICE: Extended attributes are not restored.
WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.
The partition should be unmounted to undelete any files without further data loss.
If the partition is not currently mounted, this message indicates
it was improperly unmounted, and you should run fsck before continuing.
If you decide to continue, extundelete may overwrite some of the deleted
files and make recovering those files impossible. You should unmount the
file system and check it with fsck before using extundelete.
Would you like to continue? (y/n)
y
Loading filesystem metadata ... 151 groups loaded.
Loading journal descriptors ... 22517 descriptors loaded.
Searching for recoverable inodes in directory /usr/local/src/package ...
1679 recoverable inodes found.
Looking through the directory structure for deleted files ...
Block 578312 is allocated.
Unable to restore inode 146713 (usr/local/src/package/redis-2.2.5.tgz): Space has been reallocated.
Unable to restore inode 539531 (usr/local/src/package/libevent-master): Space has been reallocated.
1670 recoverable inodes still lost.
输出案例

四、完成恢复后续工做

# 恢复数据后,会把恢复数据送到当前路径的RECOVERED_FILES/内,再把恢复的数据拿回原处
cp RECOVERED_FILES/xxx/xxx/* /xxx/xxx/xxx/

结束..

相关文章
相关标签/搜索