IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Linux:使用ext3grep做数据恢复

    Adamhuan发表于 2016-08-26 15:57:24
    love 0

    本文演示如何在Linux下恢复由“rm”这样的高危命令带来的不可挽回的后果。

    首先,看看我们的数据:

    [root@mysql-1 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_mysql1-lv_root
                           18G  3.8G   13G  24% /
    tmpfs                 932M   68K  932M   1% /dev/shm
    /dev/sda1             477M   40M  412M   9% /boot
    /dev/sdb1             3.0G  575M  2.3G  21% /ext_me
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# du -sh /ext_me/
    507M	/ext_me/
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|" /ext_me/*
    -rw-r----- 1 root root 137502311 |2016-08-26|06:05:06| /ext_me/mysql-bin.000001
    -rw-r--r-- 1 root root   3888444 |2016-08-26|06:05:22| /ext_me/MySQL-devel-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  18302217 |2016-08-26|06:05:22| /ext_me/MySQL-client-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  69533814 |2016-08-26|06:05:24| /ext_me/MySQL-embedded-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root   5199241 |2016-08-26|06:05:28| /ext_me/MySQL-shared-compat-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root   2095112 |2016-08-26|06:05:28| /ext_me/MySQL-shared-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  52325627 |2016-08-26|06:05:28| /ext_me/MySQL-server-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  30768655 |2016-08-26|06:05:29| /ext_me/web_adamhuan_wx0817.zip
    -rw-r--r-- 1 root root  43010559 |2016-08-26|06:05:29| /ext_me/MySQL-test-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root 137062162 |2016-08-26|06:05:31| /ext_me/web_adamhuan_wx.sql
    -rw-r--r-- 1 root root  30687895 |2016-08-26|06:05:37| /ext_me/web_adamhuan_wx.zip
    
    /ext_me/lost+found:
    total 0
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# du -sh /ext_me/*
    16K	/ext_me/lost+found
    132M	/ext_me/mysql-bin.000001
    18M	/ext_me/MySQL-client-5.5.37-1.rhel5.x86_64.rpm
    3.8M	/ext_me/MySQL-devel-5.5.37-1.rhel5.x86_64.rpm
    67M	/ext_me/MySQL-embedded-5.5.37-1.rhel5.x86_64.rpm
    50M	/ext_me/MySQL-server-5.5.37-1.rhel5.x86_64.rpm
    2.1M	/ext_me/MySQL-shared-5.5.37-1.rhel5.x86_64.rpm
    5.0M	/ext_me/MySQL-shared-compat-5.5.37-1.rhel5.x86_64.rpm
    42M	/ext_me/MySQL-test-5.5.37-1.rhel5.x86_64.rpm
    30M	/ext_me/web_adamhuan_wx0817.zip
    131M	/ext_me/web_adamhuan_wx.sql
    30M	/ext_me/web_adamhuan_wx.zip
    [root@mysql-1 ~]#
    [root@mysql-1 ~]# mount
    /dev/mapper/vg_mysql1-lv_root on / type ext4 (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    tmpfs on /dev/shm type tmpfs (rw)
    /dev/sda1 on /boot type ext4 (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    /dev/sdb1 on /ext_me type ext3 (rw)
    [root@mysql-1 ~]#

    开始执行删除:

    [root@mysql-1 ~]# cd /ext_me/
    [root@mysql-1 ext_me]# ls -ltr
    total 518548
    drwx------ 2 root root     16384 Aug 26 06:03 lost+found
    -rw-r----- 1 root root 137502311 Aug 26 06:05 mysql-bin.000001
    -rw-r--r-- 1 root root   3888444 Aug 26 06:05 MySQL-devel-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  18302217 Aug 26 06:05 MySQL-client-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  69533814 Aug 26 06:05 MySQL-embedded-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root   5199241 Aug 26 06:05 MySQL-shared-compat-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root   2095112 Aug 26 06:05 MySQL-shared-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  52325627 Aug 26 06:05 MySQL-server-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root  30768655 Aug 26 06:05 web_adamhuan_wx0817.zip
    -rw-r--r-- 1 root root  43010559 Aug 26 06:05 MySQL-test-5.5.37-1.rhel5.x86_64.rpm
    -rw-r--r-- 1 root root 137062162 Aug 26 06:05 web_adamhuan_wx.sql
    -rw-r--r-- 1 root root  30687895 Aug 26 06:05 web_adamhuan_wx.zip
    [root@mysql-1 ext_me]# 
    [root@mysql-1 ext_me]# rm -rf *
    [root@mysql-1 ext_me]# ls -ltr
    total 0
    [root@mysql-1 ext_me]# cd
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_mysql1-lv_root
                           18G  3.8G   13G  24% /
    tmpfs                 932M   68K  932M   1% /dev/shm
    /dev/sda1             477M   40M  412M   9% /boot
    /dev/sdb1             3.0G   69M  2.8G   3% /ext_me
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# du -sh /ext_me/
    4.0K	/ext_me/
    [root@mysql-1 ~]#

    可以看到,真的全部都删没咯。

    为了防止再写入数据,保留故障现场,我们先把/ext_me:umount

    [root@mysql-1 ~]# umount /ext_me/
    [root@mysql-1 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_mysql1-lv_root
                           18G  3.8G   13G  24% /
    tmpfs                 932M   68K  932M   1% /dev/shm
    /dev/sda1             477M   40M  412M   9% /boot
    [root@mysql-1 ~]#

    这时候,就需要ext3grep了。

    安装依赖包:
    1. yum install -y e2fsprogs-devel
    2. yum install -y gcc
    3. yum install -y gcc-c++

    [root@mysql-1 ~]# rpm -qa | grep --color e2fsprogs
    e2fsprogs-1.41.12-22.el6.x86_64
    e2fsprogs-libs-1.41.12-22.el6.x86_64
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# yum list | grep --color e2fsprogs
    e2fsprogs.x86_64                           1.41.12-22.el6                @anaconda-CentOS-201605220104.x86_64/6.8
    e2fsprogs-libs.x86_64                      1.41.12-22.el6                @anaconda-CentOS-201605220104.x86_64/6.8
    e2fsprogs-devel.i686                       1.41.12-22.el6                base   
    e2fsprogs-devel.x86_64                     1.41.12-22.el6                base   
    e2fsprogs-libs.i686                        1.41.12-22.el6                base   
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# yum install -y e2fsprogs-devel
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Setting up Install Process
    Loading mirror speeds from cached hostfile
     * base: mirrors.nwsuaf.edu.cn
     * extras: mirrors.nwsuaf.edu.cn
     * updates: mirrors.nwsuaf.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package e2fsprogs-devel.x86_64 0:1.41.12-22.el6 will be installed
    --> Processing Dependency: libcom_err-devel = 1.41.12-22.el6 for package: e2fsprogs-devel-1.41.12-22.el6.x86_64
    --> Processing Dependency: pkgconfig(com_err) for package: e2fsprogs-devel-1.41.12-22.el6.x86_64
    --> Running transaction check
    ---> Package libcom_err-devel.x86_64 0:1.41.12-22.el6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================================================================================
     Package                                 Arch                          Version                                Repository                   Size
    ================================================================================================================================================
    Installing:
     e2fsprogs-devel                         x86_64                        1.41.12-22.el6                         base                        160 k
    Installing for dependencies:
     libcom_err-devel                        x86_64                        1.41.12-22.el6                         base                         33 k
    
    Transaction Summary
    ================================================================================================================================================
    Install       2 Package(s)
    
    Total download size: 193 k
    Installed size: 563 k
    Downloading Packages:
    (1/2): e2fsprogs-devel-1.41.12-22.el6.x86_64.rpm                                                                         | 160 kB     00:00     
    (2/2): libcom_err-devel-1.41.12-22.el6.x86_64.rpm                                                                        |  33 kB     00:00     
    ------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                           172 kB/s | 193 kB     00:01     
    warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    Importing GPG key 0xC105B9DE:
     Userid : CentOS-6 Key (CentOS 6 Official Signing Key) 
     Package: centos-release-6-8.el6.centos.12.3.x86_64 (@anaconda-CentOS-201605220104.x86_64/6.8)
     From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Warning: RPMDB altered outside of yum.
    ** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
    2:postfix-2.6.6-6.el6_7.1.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
    2:postfix-2.6.6-6.el6_7.1.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
    2:postfix-2.6.6-6.el6_7.1.x86_64 has missing requires of mysql-libs
      Installing : libcom_err-devel-1.41.12-22.el6.x86_64                                                                                       1/2 
      Installing : e2fsprogs-devel-1.41.12-22.el6.x86_64                                                                                        2/2 
      Verifying  : libcom_err-devel-1.41.12-22.el6.x86_64                                                                                       1/2 
      Verifying  : e2fsprogs-devel-1.41.12-22.el6.x86_64                                                                                        2/2 
    
    Installed:
      e2fsprogs-devel.x86_64 0:1.41.12-22.el6                                                                                                       
    
    Dependency Installed:
      libcom_err-devel.x86_64 0:1.41.12-22.el6                                                                                                      
    
    Complete!
    [root@mysql-1 ~]#
    
    [root@mysql-1 ext3grep-0.10.2]# yum install -y gcc
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Setting up Install Process
    Loading mirror speeds from cached hostfile
     * base: mirrors.nwsuaf.edu.cn
     * extras: mirrors.nwsuaf.edu.cn
     * updates: mirrors.nwsuaf.edu.cn
    Package gcc-4.4.7-17.el6.x86_64 already installed and latest version
    Nothing to do
    [root@mysql-1 ext3grep-0.10.2]#

    安装ext3grep:

    [root@mysql-1 ~]# cd /software
    [root@mysql-1 software]# ls -ltr | grep ext3grep
    [root@mysql-1 software]# ls -ltr | grep ext3grep
    -rw-r--r--  1 root root    236364 Aug 26 06:21 ext3grep-0.10.2.tar.gz
    [root@mysql-1 software]#
    [root@mysql-1 software]# tar -xzf ext3grep-0.10.2.tar.gz 
    [root@mysql-1 software]# ls -ltr | grep ext3grep
    drwxr-xr-x  3 1000 1000      4096 Apr 19  2010 ext3grep-0.10.2
    -rw-r--r--  1 root root    236364 Aug 26 06:21 ext3grep-0.10.2.tar.gz
    [root@mysql-1 software]# cd ext3grep-0.10.2
    [root@mysql-1 ext3grep-0.10.2]# ls
    aclocal.m4    config.h.in  configure     depcomp  install-sh    Makefile.am  missing  README
    config.guess  config.sub   configure.ac  INSTALL  LICENSE.GPL2  Makefile.in  NEWS     src
    [root@mysql-1 ext3grep-0.10.2]# 
    [root@mysql-1 software]# mkdir /usr/local/ext3grep
    [root@mysql-1 software]#
    [root@mysql-1 ext3grep-0.10.2]# ./configure --prefix=/usr/local/ext3grep
    (... ... 过多的输出)
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking whether byte ordering is bigendian... no
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking for compiler with PCH support... yes
    checking for special C compiler options needed for large files... no
    checking for _FILE_OFFSET_BITS value needed for large files... no
    checking ext2fs/ext2_fs.h usability... yes
    checking ext2fs/ext2_fs.h presence... yes
    checking for ext2fs/ext2_fs.h... yes
    checking ext2fs/ext2fs.h usability... yes
    checking ext2fs/ext2fs.h presence... yes
    checking for ext2fs/ext2fs.h... yes
    configure: creating ./config.status
    config.status: creating src/timestamp-sys.h
    config.status: creating sys.h
    config.status: creating Makefile
    config.status: creating src/Makefile
    config.status: creating config.h
    config.status: executing depfiles commands
    [root@mysql-1 ext3grep-0.10.2]#
    
    [root@mysql-1 ext3grep-0.10.2]# make
    (... ... 过多的输出)
    test -f 'locate.cc' || echo './'`locate.cc
    g++ -g -O2 -DUSE_MMAP=1 -I/usr/include/ext2fs -I/usr/include/et    -include pch.h    -o ext3grep ext3grep-custom.o ext3grep-accept.o ext3grep-blocknr_vector_type.o ext3grep-commandline.o ext3grep-directories.o ext3grep-dir_inode_to_block.o ext3grep-dump_hex_to.o ext3grep-dump_names.o ext3grep-init_journal_consts.o ext3grep-get_block.o ext3grep-globals.o ext3grep-histogram.o ext3grep-indirect_blocks.o ext3grep-init_consts.o ext3grep-init_directories.o ext3grep-init_files.o ext3grep-inode.o ext3grep-inode_refers_to.o ext3grep-is_blockdetection.o ext3grep-journal.o ext3grep-last_undeleted_directory_inode_refering_to_block.o ext3grep-load_meta_data.o ext3grep-ostream_operators.o ext3grep-Parent.o ext3grep-print_directory.o ext3grep-print_directory_inode.o ext3grep-print_dir_entry_long_action.o ext3grep-printing.o ext3grep-print_inode_to.o ext3grep-print_symlink.o ext3grep-restore.o ext3grep-show_hardlinks.o ext3grep-show_journal_inodes.o ext3grep-utils.o ext3grep-ext3grep.o ext3grep-locate.o     
    make[3]: Leaving directory `/software/ext3grep-0.10.2/src'
    make[2]: Leaving directory `/software/ext3grep-0.10.2/src'
    Making all in .
    make[2]: Entering directory `/software/ext3grep-0.10.2'
    make[2]: Leaving directory `/software/ext3grep-0.10.2'
    make[1]: Leaving directory `/software/ext3grep-0.10.2'
    [root@mysql-1 ext3grep-0.10.2]# 
    
    [root@mysql-1 ext3grep-0.10.2]# make install
    (... ... 过多的输出。)
    test -f 'locate.cc' || echo './'`locate.cc
    g++ -g -O2 -DUSE_MMAP=1 -I/usr/include/ext2fs -I/usr/include/et    -include pch.h    -o ext3grep ext3grep-custom.o ext3grep-accept.o ext3grep-blocknr_vector_type.o ext3grep-commandline.o ext3grep-directories.o ext3grep-dir_inode_to_block.o ext3grep-dump_hex_to.o ext3grep-dump_names.o ext3grep-init_journal_consts.o ext3grep-get_block.o ext3grep-globals.o ext3grep-histogram.o ext3grep-indirect_blocks.o ext3grep-init_consts.o ext3grep-init_directories.o ext3grep-init_files.o ext3grep-inode.o ext3grep-inode_refers_to.o ext3grep-is_blockdetection.o ext3grep-journal.o ext3grep-last_undeleted_directory_inode_refering_to_block.o ext3grep-load_meta_data.o ext3grep-ostream_operators.o ext3grep-Parent.o ext3grep-print_directory.o ext3grep-print_directory_inode.o ext3grep-print_dir_entry_long_action.o ext3grep-printing.o ext3grep-print_inode_to.o ext3grep-print_symlink.o ext3grep-restore.o ext3grep-show_hardlinks.o ext3grep-show_journal_inodes.o ext3grep-utils.o ext3grep-ext3grep.o ext3grep-locate.o     
    make[3]: Entering directory `/software/ext3grep-0.10.2/src'
    test -z "/usr/local/ext3grep/bin" || /bin/mkdir -p "/usr/local/ext3grep/bin"
      /usr/bin/install -c ext3grep '/usr/local/ext3grep/bin'
    make[3]: Nothing to be done for `install-data-am'.
    make[3]: Leaving directory `/software/ext3grep-0.10.2/src'
    make[2]: Leaving directory `/software/ext3grep-0.10.2/src'
    make[1]: Leaving directory `/software/ext3grep-0.10.2/src'
    Making install in .
    make[1]: Entering directory `/software/ext3grep-0.10.2'
    make[2]: Entering directory `/software/ext3grep-0.10.2'
    make[2]: Nothing to be done for `install-exec-am'.
    make[2]: Nothing to be done for `install-data-am'.
    make[2]: Leaving directory `/software/ext3grep-0.10.2'
    make[1]: Leaving directory `/software/ext3grep-0.10.2'
    [root@mysql-1 ext3grep-0.10.2]#

    这样,就安装好了。

    开始使用ext3grep恢复数据。

    1. 扫描分区:

    [root@mysql-1 ~]# /usr/local/ext3grep/bin/ext3grep /dev/sdb1 --ls --inode 2
    Running ext3grep version 0.10.2
    WARNING: I don't know what EXT3_FEATURE_COMPAT_EXT_ATTR is.
    Number of groups: 24
    Loading group metadata... done
    Minimum / maximum journal block: 328194 / 344595
    Loading journal descriptors... sorting... done
    The oldest inode block that is still in the journal, appears to be from 1472162706 = Fri Aug 26 06:05:06 2016
    Number of descriptors in journal: 203; min / max sequence numbers: 2 / 7
    Inode is Allocated
    Finding all blocks that might be directories.
    D: block containing directory start, d: block containing more directory entries.
    Each plus represents a directory start that references the same inode as a directory start that we found previously.
    
    Searching group 0: DD
    Searching group 1: 
    Searching group 2: 
    Searching group 3: 
    Searching group 4: 
    Searching group 5: 
    Searching group 6: 
    Searching group 7: 
    Searching group 8: 
    Searching group 9: 
    Searching group 10: ++++
    Searching group 11: 
    Searching group 12: 
    Searching group 13: 
    Searching group 14: 
    Searching group 15: 
    Searching group 16: 
    Searching group 17: 
    Searching group 18: 
    Searching group 19: 
    Searching group 20: 
    Searching group 21: 
    Searching group 22: 
    Searching group 23: 
    Writing analysis so far to 'sdb1.ext3grep.stage1'. Delete that file if you want to do this stage again.
    Result of stage one:
      2 inodes are referenced by one or more directory blocks, 1 of those inodes is still allocated.
      1 inodes are referenced by more than one directory block, 1 of those inodes is still allocated.
      0 blocks contain an extended directory.
    Result of stage two:
      1 of those inodes could be resolved because it is still allocated.
    All directory inodes are accounted for!
    
    
    Writing analysis so far to 'sdb1.ext3grep.stage2'. Delete that file if you want to do this stage again.
    The first block of the directory is 707.
    Inode 2 is directory "".
    Directory block 707:
              .-- File type in dir_entry (r=regular file, d=directory, l=symlink)
              |          .-- D: Deleted ; R: Reallocated
    Indx Next |  Inode   | Deletion time                        Mode        File name
    ==========+==========+----------------data-from-inode------+-----------+=========
       0    1 d       2                                         drwxr-xr-x  .
       1  end d       2                                         drwxr-xr-x  ..
       2    3 d      11  D 1472163398 Fri Aug 26 06:16:38 2016  drwx------  lost+found
       3    4 r      12  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r-----  mysql-bin.000001
       4    5 r      13  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-client-5.5.37-1.rhel5.x86_64.rpm
       5    6 r   24577  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-devel-5.5.37-1.rhel5.x86_64.rpm
       6    7 r   24578  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-embedded-5.5.37-1.rhel5.x86_64.rpm
       7    8 r   24579  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-server-5.5.37-1.rhel5.x86_64.rpm
       8    9 r   24580  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-shared-5.5.37-1.rhel5.x86_64.rpm
       9   10 r   24581  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-shared-compat-5.5.37-1.rhel5.x86_64.rpm
      10   11 r   40961  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  MySQL-test-5.5.37-1.rhel5.x86_64.rpm
      11   12 r   40962  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  web_adamhuan_wx0817.zip
      12   13 r   40963  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  web_adamhuan_wx.sql
      13  end r   73729  D 1472163398 Fri Aug 26 06:16:38 2016  rrw-r--r--  web_adamhuan_wx.zip
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|"
    total 104
    -rw-r--r--. 1 root root  9360 |2016-08-22|22:54:37| install.log.syslog
    -rw-r--r--. 1 root root 44298 |2016-08-22|22:57:26| install.log
    -rw-------. 1 root root  1503 |2016-08-22|22:57:29| anaconda-ks.cfg
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Videos
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Templates
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Public
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Pictures
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Music
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Downloads
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Documents
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Desktop
    -rw-r--r--  1 root root   205 |2016-08-26|06:51:37| sdb1.ext3grep.stage1
    -rw-r--r--  1 root root   132 |2016-08-26|06:51:37| sdb1.ext3grep.stage2
    [root@mysql-1 ~]#

    2. 恢复数据:

    [root@mysql-1 ~]# /usr/local/ext3grep/bin/ext3grep /dev/sdb1 --restore-file mysql-bin.000001
    Running ext3grep version 0.10.2
    WARNING: I don't know what EXT3_FEATURE_COMPAT_EXT_ATTR is.
    Number of groups: 24
    Minimum / maximum journal block: 328194 / 344595
    Loading journal descriptors... sorting... done
    The oldest inode block that is still in the journal, appears to be from 1472162706 = Fri Aug 26 06:05:06 2016
    Number of descriptors in journal: 203; min / max sequence numbers: 2 / 7
    Writing output to directory RESTORED_FILES/
    Loading sdb1.ext3grep.stage2... done
    Restoring mysql-bin.000001
    [root@mysql-1 ~]#

    可以看到,数据恢复成功。

    3. 查看恢复出来的数据:

    [root@mysql-1 ~]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|"
    total 108
    -rw-r--r--. 1 root root  9360 |2016-08-22|22:54:37| install.log.syslog
    -rw-r--r--. 1 root root 44298 |2016-08-22|22:57:26| install.log
    -rw-------. 1 root root  1503 |2016-08-22|22:57:29| anaconda-ks.cfg
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Videos
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Templates
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Public
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Pictures
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Music
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Downloads
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Documents
    drwxr-xr-x. 2 root root  4096 |2016-08-23|00:01:55| Desktop
    -rw-r--r--  1 root root   205 |2016-08-26|06:51:37| sdb1.ext3grep.stage1
    -rw-r--r--  1 root root   132 |2016-08-26|06:51:37| sdb1.ext3grep.stage2
    drwxr-xr-x  2 root root  4096 |2016-08-26|06:55:32| RESTORED_FILES
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|" RESTORED_FILES/
    total 134280
    -rw-r----- 1 root root 137502311 |2016-08-26|06:05:06| mysql-bin.000001
    [root@mysql-1 ~]# 
    [root@mysql-1 ~]# du -sh RESTORED_FILES/mysql-bin.000001 
    132M	RESTORED_FILES/mysql-bin.000001
    [root@mysql-1 ~]#

    至此,数据恢复完成。
    ——————————————————————
    Done。



沪ICP备19023445号-2号
友情链接