1. 程式人生 > >Linux:extundelete(資料恢復)

Linux:extundelete(資料恢復)

https://sourceforge.net/projects/extundelete/

[[email protected] ~]# yum install -y e2fsprogs e2fsprogs-devel
[[email protected] ~]# tar jxvf extundelete-0.2.4.tar.bz2 
[[email protected] ~]# cd extundelete-0.2.4
[[email protected]
 extundelete-0.2.4]# ./configure [[email protected] extundelete-0.2.4]# make [[email protected] extundelete-0.2.4]# make install [[email protected] ~]# extundelete --help Usage: extundelete [options] [--] device-file Options:   --version, -[vV]       Print version and exit successfully.   --help,                Print this help and exit successfully.   --superblock           Print contents of superblock in addition to the rest.                          If no action is specified then this option is implied.   --journal              Show content of journal.   --after dtime          Only process entries deleted on or after 'dtime'.   --before dtime         Only process entries deleted before 'dtime'. Actions:   --inode ino            Show info on inode 'ino'.   --block blk            Show info on block 'blk'.   --restore-inode ino[,ino,...]                          Restore the file(s) with known inode number 'ino'.                          The restored files are created in ./RECOVERED_FILES                          with their inode number as extension (ie, file.12345).   --restore-file 'path'  Will restore file 'path'. 'path' is relative to root                          of the partition and does not start with a '/'                          The restored file is created in the current                          directory as 'RECOVERED_FILES/path'.   --restore-files 'path' Will restore files which are listed in the file 'path'.                          Each filename should be in the same format as an option                          to --restore-file, and there should be one per line.   --restore-directory 'path'                          Will restore directory 'path'. 'path' is relative to the                          root directory of the file system.  The restored                          directory is created in the output directory as 'path'.   --restore-all          Attempts to restore everything.   -j journal             Reads an external journal from the named file.   -b blocknumber         Uses the backup superblock at blocknumber when opening                          the file system.   -B blocksize           Uses blocksize as the block size when opening the file                          system.  The number should be the number of bytes.   --log 0                Make the program silent.   --log filename         Logs all messages to filename. --log D1=0,D2=filename   Custom control of log messages with comma-separated    Examples below:       list of options.  Dn must be one of info, warn, or    --log info,error      error.  Omission of the '=name' results in messages    --log warn=0          with the specified level to be logged to the console.    --log error=filename  If the parameter is '=0', logging for the specified                          level will be turned off.  If the parameter is                          '=filename', messages with that level will be written                          to filename.    -o directory          Save the recovered files to the named directory.                          The restored files are created in a directory                          named 'RECOVERED_FILES/' by default.                           [
[email protected]
 ~]# cd /usr/local/src [[email protected] src]# ls -l total 31452 drwxr-xr-x 33 7161 31415     4096 Sep 10 18:23 mysql-5.6.42 -rw-r--r--  1 root root  32201731 Jan 11 16:37 mysql-5.6.42.tar.gz [
[email protected]
 src]# rm -rf * [[email protected] ~]# umount /usr/local/src [[email protected] ~]# extundelete /dev/sdb1 --inode 2 NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 640 groups loaded. Group: 0 Contents of inode 2: 0000 | ed 41 00 00 00 10 00 00 f6 55 38 5c 3f 56 38 5c | .A.......U8\?V8\ 0010 | 3f 56 38 5c 00 00 00 00 00 00 02 00 08 00 00 00 | ?V8\............ 0020 | 00 00 00 00 0f 00 00 00 21 24 00 00 00 00 00 00 | ........!$...... 0030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 0040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 0050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 0060 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 0070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 0080 | 1c 00 00 00 00 c2 2c 34 00 c2 2c 34 94 0d be 0e | ......,4..,4.... 0090 | 70 48 38 5c 00 00 00 00 00 00 00 00 00 00 00 00 | pH8\............ 00a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 00b0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 00c0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 00d0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 00e0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ 00f0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................ Inode is Allocated File mode: 16877 Low 16 bits of Owner Uid: 0 Size in bytes: 4096 Access time: 1547195894 Creation time: 1547195967 Modification time: 1547195967 Deletion Time: 0 Low 16 bits of Group Id: 0 Links count: 2 Blocks count: 8 File flags: 0 File version (for NFS): 0 File ACL: 0 Directory ACL: 0 Fragment address: 0 Direct blocks: 9249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Indirect block: 0 Double indirect block: 0 Triple indirect block: 0 File name                                       | Inode number | Deleted status .                                                 2 ..                                                2 mysql-5.6.42.tar.gz                               11             Deleted mysql-5.6.42                                      1835009        Deleted [[email protected] ~]# extundelete /dev/sdb1  --restore-file mysql-5.6.42.tar.gz NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 640 groups loaded. Loading journal descriptors ... 3717 descriptors loaded. Successfully restored file mysql-5.6.42.tar.gz [[email protected] ~]# extundelete /dev/sdb1 --restore-directory mysql-5.6.42 NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 640 groups loaded. Loading journal descriptors ... 3717 descriptors loaded. Searching for recoverable inodes in directory mysql-5.6.42 ...  15308 recoverable inodes found. Looking through the directory structure for deleted files ...  2 recoverable inodes still lost. [[email protected] ~]# cd RECOVERED_FILES [[email protected] RECOVERED_FILES]# ls -l total 31452 drwxr-xr-x 33 root root     4096 Jan 11 16:41 mysql-5.6.42 -rw-r--r--  1 root root 32201731 Jan 11 16:41 mysql-5.6.42.tar.gz