How to recover corrupted Eclipse workspace?

2019-01-16 10:47发布

I just managed to corrupt contents of my Eclipse .metadata directory. Starting up with eclipse -clean did not work out. Deleting .metadata and then importing all projects, plugins and setting does not sound too interesting. I ended up moving .metadata/.plugins/org.eclipse.core.resources/ elsewhere and reimporting my projects only.

Are there any tools or best practices to recover workspace?

15条回答
小情绪 Triste *
2楼-- · 2019-01-16 11:20

When workspace is damaged and Eclipse cannot start, even using the -clean option, removing single file workspace/.metadata/.plugins/org.eclipse.core.resources/.snap may help (source: comments to article http://letsgetdugg.com/2009/04/19/recovering-a-corrupt-eclipse-workspace/).

Update: when Eclipse 4.X cannot start after crash, try to start with -clearPersistedState option; if it didn't help then remove file workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi (sources: http://www.eclipse.org/forums/index.php/m/1269045/ http://www.eclipse.org/forums/index.php/t/522428/ https://bugs.eclipse.org/bugs/show_bug.cgi?id=404873). Note: you'll lose configuration of your perspective/views/tabs.

Update: Subversive plugin may be responsible for unability to start Eclipse with corrupted metadata. If you have Subversive plugin installed, update it to latest build (at least 0.7.9.I20120210-1700) from update-site. Related bugs 372621 and 370374 were fixed by Subversive developers.

查看更多
成全新的幸福
3楼-- · 2019-01-16 11:21

One more solution that I've discovered by accident, and may help someone:

  1. Back up the corrupted workspace.
  2. Move half of you projects to some temporary location.
  3. Start Eclipse, if it works, go to step 5.
  4. Move the half of projects you've removed back into the workspace, move out the other half. If you've already done that, keep removing/readding your projects in a binary search manner. Go to step 3.
  5. Exit Eclipse, move back all your projects, and start it again. You should see now that some of your projects are closed (and in the wrong working sets). Re-open your projects and move them to the correct working sets.

In my case, it was a project that got corrupted, and not the entire workspace (attempting to import said project into a fresh workspace caused it to fail as well). So, I've started to search for the faulty project - instead, I got the result described above.

查看更多
Deceive 欺骗
4楼-- · 2019-01-16 11:21

I know this sounds obvious, but if I'm writing code for a living I would be sure to do a full backup weekly, with corresponding incremental backups daily.

Simple and easy recovery.

For a simple way to backup your eclipse directory and assuming your using Linux, you could use rsync.

rsync -ar <eclipse-dir> <backup-eclipse-dir>

You can put this in cron and have it backup your files automatically. It will only copy over the changed files to your backup-eclipse-dir on subsequent runs.

查看更多
相关推荐>>
5楼-- · 2019-01-16 11:24

You should be able to start your workspace after deleting the following file: .metadata.plugins\org.eclipse.e4.workbench\workbench.xmi as shown here :

查看更多
家丑人穷心不美
6楼-- · 2019-01-16 11:25

In my case, it was not the workspace that was broken but Eclipse itself. Even though it seemed like workspace is broken (the same error dialog, etc.), all I had to do was reinstall Eclipse and point it to the old workspace. You can't really repair a broken workspace if it is the workspace that is broken but you can do so just for good measure, maybe it'll work.

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-01-16 11:25

If the workspace is not that big you could backup to say dropbox as a private locked folder.

查看更多
登录 后发表回答