BBS水木清华站∶精华区

发信人: moonstone (stone), 信区: Linux        
标  题:  我的 文件恢复过程 !使用perl 脚本 !  
发信站: BBS 水木清华站 (Tue Dec 19 21:33:17 2000) 
 
第一步:找出误删除 当天 所释放的 节点  使用 perl script : RescueFile.perl 
内容如下: 
 
#!/usr/bin/perl    -w 
 
# this perl script and next one is used to rescue  files which are wrong delete 
 
# in this case  :  files which are wrong deleted  were in  /dev/hda5 
 
` echo lsdel | /sbin/debugfs /dev/hda5 >  /usr/Rescue_Temp/lsdel18.out  ` ; 
 
######## 找出某一天释放的节点 ( Inode )   in this case  :  Dec 18 
 
` gawk '/Dec 18/ { print $1 }' /usr/Rescue_Temp/lsdel18.out >  /usr/Rescue_Temp 
lsdel_Dec_18_Inode.out  ` ; 
 
这一步后 当天 所释放的 节点 就 在文件/usr/Rescue_Temp/lsdel_Dec_18_Inode.out 
里了 ! 
 
 
第二步 : 开始恢复文件  perl  script :  kitty.perl 
 
#!/usr/bin/perl  -w 
 
# this perl script is used to get input  from file line by line then  deal with 
them 
 
 
$i=0 ;   #  设置记数器 
 
while (<>){ 
 
 
        $Inode=$_ ; 
 
        chomp ($Inode) ; 
 
        ` echo "dump -p <$Inode>  /usr/Rescue_Temp/RescuedFile.00$i " | /sbin/d 
bugfs  /dev/hda5 ` ; 
 
        $i++ ; 
 

 
 
运行 perl script : 
                       kitty.perl   /usr/Rescue_Temp/lsdel_Dec_18_Inode.out 
 
 
运行后 文件就恢复到 目录  /usr/Rescue_Temp/ 下 , 文件名为 RescuedFile.00xxx 
 
 
我用此方法 成功地恢复了 一批 文本文件  和 一个 大苹果 ! 
 
 
确陷:          不能恢复文件名 ! 
 
如果是非文本文件或源程序 恢复过来后 看不懂 !   
 
如果知道删除的确切时间 ( 精确到 小时 ) 还可以进一步修改第一个 perl script ! 
 
-- 
 
※ 修改:·moonstone 於 Dec 19 21:42:05 修改本文·[FROM:  202.119.21.233] 
※ 来源:·BBS 水木清华站 smth.org·[FROM: 202.119.21.233] 

BBS水木清华站∶精华区