标签:linux extundelete
在生产环境,运维人员有时候会误删文件,或者一些别有用心的人故意删除你服务器数据上的重要数据。出现这种情况导致数据丢失,对公司可能造成重大影响,因此你的饭碗也有可能不保。在linux环境下有一些帮助我们恢复丢失数据的软件,其中"extundelete"就是一个很强大的开源软件。
首先,下载extundelete,编译安装它。
[root@localhost opt]# wget http://sourceforge.net/projects/extundelete/files/latest/download
[root@localhost opt]# tar jxf extundelete-0.2.4.tar.bz2
[root@localhost opt]# ls
extundelete-0.2.4 extundelete-0.2.4.tar.bz2
[root@localhost opt]# cd extundelete-0.2.4
[root@localhost extundelete-0.2.4]# ./configure
[root@localhost extundelete-0.2.4]#make && make install
测试建立测试环境
[root@localhost extundelete-0.2.4]# mkdir /movie
[root@localhost extundelete-0.2.4]# mkfs.ext3 /dev/sdb
[root@localhost ~]# mount /dev/sdb /movie/
[root@localhost ~]# vim /movie/test
[root@localhost ~]# mkdir /movie/data
[root@localhost ~]# cp /etc/passwd /movie/data/
[root@localhost ~]# rm -rf /movie/*
[root@localhost ~]# umount /dev/sdb
查看/dev/sdb的数据情况,可以看到被删除的文件"deleted".
[root@localhost /]# extundelete /dev/sdb --inode 2
File name | Inode number | Deleted status
. 2
.. 2
.test.swp 11 Deleted
test 12 Deleted
data 751728 Deleted
恢复单个文件:
[root@localhost /]# extundelete /dev/sdb --restore-file test
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 80 groups loaded.
Loading journal descriptors ... 39 descriptors loaded.
Successfully restored file test
恢复单个目录:
[root@localhost ~]# extundelete /dev/sdb --restore-directory bbq
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 80 groups loaded.
Loading journal descriptors ... 34 descriptors loaded.
Searching for recoverable inodes in directory bbq ...
2 recoverable inodes found.
Looking through the directory structure for deleted files ...
Unable to restore inode 557058 (bbq/qweqweqw): Space has been reallocated.
1 recoverable inodes still lost.
恢复所有文件:
[root@localhost ~]# extundelete /dev/sdb --restore-all
extundelete会把文件恢复到当前目录的“ RECOVERED_FILES”里面,可以查看数据是否有还原回来
[root@localhost /]# ls RECOVERED_FILES/
test test.v1
本文出自 “龙爱雪琪” 博客,请务必保留此出处http://dragon123.blog.51cto.com/9152073/1557737
标签:linux extundelete
原文地址:http://dragon123.blog.51cto.com/9152073/1557737