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/

結束..

相關文章
相關標籤/搜索