尝试去恢复被删除的数据,虽然失败了,下次也算点经验了

梦康 2016-11-11 00:00:00 643

博客的附件全部丢失,我很郁闷!里面很多图都是我花了很长时间画出来的。某一张图可能就耗费我2个多小时。第一次遇到 linux 需要恢复有价值的数据,处理的晚了点,也没经验,不知道和我新建了同名目录是否有关系,导致没有恢复成功,但是恢复了刚刚前一会删除的软件包。所以误删之后,马上卸载磁盘,然后恢复,可能还是有希望的。

参考这篇:http://ixdba.blog.51cto.com/2895551/1566856/

yum install e2fsprogs* -y
[root@VM_132_97_centos soft]#tar jxvf  extundelete-0.2.4.tar.bz2
[root@VM_132_97_centos soft]# cd extundelete-0.2.4/
[root@VM_132_97_centos extundelete-0.2.4]# ./configure 
Configuring extundelete 0.2.4
Writing generated files to disk
[root@VM_132_97_centos extundelete-0.2.4]# ls
acinclude.m4  autogen.sh  config.h.in  config.status  configure.ac  install-sh  Makefile     Makefile.in  README  stamp-h1
aclocal.m4    config.h    config.log   configure      depcomp       LICENSE     Makefile.am  missing      src
[root@VM_132_97_centos extundelete-0.2.4]# make
make -s all-recursive
Making all in src
extundelete.cc:571: 警告:未使用的参数‘flags’
[root@VM_132_97_centos extundelete-0.2.4]# make install
Making install in src
  /usr/bin/install -c extundelete '/usr/local/bin'
[root@VM_132_97_centos ~]# umount /dev/xvdb1 
umount: /data: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@VM_132_97_centos ~]# fuser -m /data
/data:                6338c  8128cm  9207 14643
[root@VM_132_97_centos ~]# ps aux|grep 9207
root      9207  0.0  0.1 117408  5804 ?        Ss   Oct15   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)                                                                    
root     30430  0.0  0.0 103184   860 pts/1    R+   13:50   0:00 grep 9207
[root@VM_132_97_centos ~]# service php-fpm stop
Gracefully shutting down php-fpm . done
[root@VM_132_97_centos ~]# fuser -m /data
/data:                6338c  8128cm 14643
[root@VM_132_97_centos ~]# ps aux|grep 14643
root     14643  0.0  0.0 202692  3832 ?        Ss   Nov10   0:00 php-fpm: master process (/usr/local/php5/etc/php-fpm.conf)                                                                      
root     30493  0.0  0.0 103184   856 pts/1    R+   13:51   0:00 grep 14643
[root@VM_132_97_centos ~]# service php5-fpm stop
Gracefully shutting down php-fpm . done
[root@VM_132_97_centos ~]# fuser -m /data
/data:                6338c  8128cm
[root@VM_132_97_centos ~]# umount /data
umount: /data: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@VM_132_97_centos ~]# ps aux|grep 6338
root      6338  0.0  0.1 133540  6044 ?        Ssl  Sep30   2:34 /usr/local/redis/bin/redis-server 127.0.0.1:6379                 
root     30765  0.0  0.0 103184   852 pts/1    R+   13:52   0:00 grep 6338
[root@VM_132_97_centos ~]# service redis stop

卸载的时候发现磁盘繁忙,只能先把各种服务都停了。

[root@VM_132_97_centos ~]# fuser -m /data
[root@VM_132_97_centos ~]# umount /data

只看到了刚刚删除的安装包,昨天被误删的东西并没有恢复

[root@VM_132_97_centos mnt]# extundelete /dev/xvdb1 --restore-all
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 400 groups loaded.
Loading journal descriptors ... 26227 descriptors loaded.
Searching for recoverable inodes in directory / ... 
15 recoverable inodes found.
Looking through the directory structure for deleted files ... 
Unable to restore inode 650452 (svndata/mengkang/db/txn-protorevs/1590-18h.rev): Space has been reallocated.
Block 11829931 is allocated.
Failed to restore inode 2950453 to file RECOVERED_FILES/soft/extundelete-0.2.4.tar.bz2:Some blocks were allocated.
10 recoverable inodes still lost.
[root@VM_132_97_centos mnt]# ls
RECOVERED_FILES
[root@VM_132_97_centos mnt]# cd RECOVERED_FILES/
[root@VM_132_97_centos RECOVERED_FILES]# ls
file.650456  file.671955  file.671956  file.671957  file.671958  file.671960  file.671961  file.671962  file.671963  file.671964  soft  svndata  WTEST.TMP
[root@VM_132_97_centos RECOVERED_FILES]# ll
总用量 52
-rw-r--r-- 1 root root    5 11月 11 13:56 file.650456
-rw-r--r-- 1 root root  148 11月 11 13:56 file.671955
-rw-r--r-- 1 root root   70 11月 11 13:56 file.671956
-rw-r--r-- 1 root root    4 11月 11 13:56 file.671957
-rw-r--r-- 1 root root  102 11月 11 13:56 file.671958
-rw-r--r-- 1 root root  137 11月 11 13:56 file.671960
-rw-r--r-- 1 root root 1022 11月 11 13:56 file.671961
-rw-r--r-- 1 root root  275 11月 11 13:56 file.671962
-rw-r--r-- 1 root root  474 11月 11 13:56 file.671963
-rw-r--r-- 1 root root  107 11月 11 13:56 file.671964
drwxr-xr-x 2 root root 4096 11月 11 13:56 soft
drwxr-xr-x 3 root root 4096 11月 11 13:56 svndata
-rw-r--r-- 1 root root 4096 11月 11 13:56 WTEST.TMP
[root@VM_132_97_centos RECOVERED_FILES]# cd soft/
[root@VM_132_97_centos soft]# ls
extundelete-0.2.4.tar.bz2.part