V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zzzmh
V2EX  ›  问与答

紧急求救! ubuntu 下误删了 idea 开发工具的所有项目的根目录

  •  
  •   zzzmh · 2021-03-30 10:58:23 +08:00 · 1603 次点击
    这是一个创建于 1363 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题
    固态硬盘,双系统,ext4 一个分区给 ubuntu
    今天手欠了,直接删了 idea 的所有项目的根目录
    首先排除了通过 idea 恢复

    至于 git 。。。我最近一周刚好没提交,也不记得开发了点啥。。。
    跑去 windows 下试了 diskgenius ,恢复数据,扫描完也只能看到项目文件夹的根目录,里面的文件完全看不见


    目前寄希望于 extundelete
    extundelete 第一次用比较陌生。。。
    试了下这个命令
    extundelete /dev/nvme0n1p6 --restore-all
    

    返回如下
    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 ... 800 groups loaded.
    Loading journal descriptors ... 段错误 (核心已转储)
    
    

    还试了这个
    extundelete /dev/nvme0n1p6 --inode 2
    

    返回如下
    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 ... 800 groups loaded.
    Group: 0
    Contents of inode 2:
    0000 | ed 41 00 00 00 10 00 00 63 80 62 60 ba e9 55 60 | .A......c.b`..U`
    0010 | ba e9 55 60 00 00 00 00 00 00 14 00 08 00 00 00 | ..U`............
    0020 | 00 00 08 00 1b 00 00 00 0a f3 01 00 04 00 00 00 | ................
    0030 | 00 00 00 00 00 00 00 00 01 00 00 00 3e 24 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 b4 80 00 00 | ................
    0080 | 20 00 09 af ec 4e 03 39 ec 4e 03 39 84 09 60 79 |  ....N.9.N.9..`y
    0090 | d6 42 d0 5f 00 00 00 00 00 00 00 00 00 00 00 00 | .B._............
    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: 1617068131
    Creation time: 1616243130
    Modification time: 1616243130
    Deletion Time: 0
    Low 16 bits of Group Id: 0
    Links count: 20
    Blocks count: 8
    File flags: 524288
    File version (for NFS): 0
    File ACL: 0
    High 32 bits of Size: 0
    Fragment address: 0
    Direct blocks: 127754, 4, 0, 0, 1, 9278, 0, 0, 0, 0, 0, 0
    Indirect block: 0
    Double indirect block: 0
    Triple indirect block: 0
    
    File name                                       | Inode number | Deleted status
    

    我现在就想知道,我是不是已经凉透了。。。。

    linux 下是不是没希望恢复了? 再去 windows 下试数据恢复还有意义吗?

    3 条回复    2021-03-30 13:30:43 +08:00
    burby
        1
    burby  
       2021-03-30 11:11:53 +08:00 via iPhone
    一周都没提交,emm.......
    所有项目的根目录,意思是所有的工程文件都没了么?
    ext 文件系统想在 win 下恢复感觉有点奇怪。
    恢复技术不了解,但是感觉重写来的比较快。
    Misakas
        2
    Misakas  
       2021-03-30 13:27:30 +08:00
    想起上次重装系统( Ubuntu )后发现色图被删掉了,急忙用工具扫了一下恢复。楼主只要删掉后没在硬盘写什么东西应该还能恢复
    zzzmh
        3
    zzzmh  
    OP
       2021-03-30 13:30:43 +08:00
    一周没提交主要还是因为其他后端小伙伴离职了,新人还没入职,我自己写自己用就懒得每天提交。
    重写一次最大的难度是新开的那个 git 分支,完全还没提交过,也不太记得我到底改了些什么。

    这次恢复数据,复盘一下,最大的问题是,我第一时间没把磁盘改只读,中间还重启过,导致 linux 下彻底失去恢复希望。

    不过最后我用了一个笨办法曲线救国,救回来了 95%,虚惊一场

    idea 有个 localhistory,可以让文件回滚到历史时间,只要回滚到今天早上删掉之前就可以了。
    但是,没有项目根目录以后,打开 idea,项目显示灰色,打开也会提示,项目文件已不存在。进不去项目的界面,就选不到 localhistory,本来觉得这条路是死循环。然后中午睡觉的时候,梦里有人和我说,新建一个同名文件夹即可进入项目界面。即:项目开发空间叫 workspaces,下面的项目叫 project_a,现在 workspaces 删掉了。idea 能看到 project_a,但是点了显示项目文件不存在,无法进去恢复。那我就手动新建文件夹 workspaces,下面新建文件夹 project_a,idea 就允许进入项目了,进去虽然是全空白,但使用 localhistory,恢复到早上 9 点,文件就回来了。也存在 2 个缺点,1 如果你刚丢失,新建同名文件夹,会彻底失去从磁盘恢复机会。2 只恢复了代码和配置文件,仍然丢失了本地 git 相关文件(这个难不倒我,下午拉一份线上的,和恢复回来的 meger 一下即可完美解决)

    感觉这个帖子参考价值不大,就让他沉了吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2750 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:37 · PVG 19:37 · LAX 03:37 · JFK 06:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.