• Extundelete 数据恢复


    Extundelete 数据恢复

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

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

    介绍

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

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

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


    搭建

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

    1、安装依赖包

    yum -y install e2fsprogs-devel gcc

    2、解压工具包

    tar jxf extundelete-0.2.4.tar.bz2

    3、指定安装目录、编译、编译安装

    ./configure ; make ; make install

    使用

    常用参数:

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

    开启恢复流程:

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

    ls -id /xxx/xxx/

    注:输出最左侧为ID号。

    2、查看被删除的上层目录 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
    输出案例

    3、恢复数据、恢复指定目录下所有删除的数据

    # 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.
    输出案例

    4、完成恢复后续工作

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

    结束..


  • 相关阅读:
    docker 知识汇总1-镜像管理
    合并两个git repository
    这一次, 信报箱震惊世界
    python实现括号分组
    linux case菜单代码示例
    oracle 11gR2 client安装(Red Hat Enterprise Linux Server release 5.5 (Tikanga) 安装ORACLE客户端)
    SYSAUX表空间过大处理
    SYSAUX表空间大于33G问题处理
    window 给链接加下划线或取消下划线
    ORACLE11G_win32监听程序不支持服务
  • 原文地址:https://www.cnblogs.com/xiangsikai/p/10779457.html
Copyright © 2020-2023  润新知