richard_coleman

A possible way to repair some File Geodatabases

Discussion created by richard_coleman on Apr 11, 2011
Latest reply on May 15, 2017 by curtvprice
I'm working in ArcGIS 10 sp1 with File Geodatabases and I've noticed that they tend to corrupt themselves with alarming regularity.  Especially when you compact them.  This happens more often when you have ArcMap and ArcCatalog open at the same time and then choose to compact a file geodatabase (tip: Make sure there is only (1) ESRI product running when you try to compact a file geodatabase).

The result is one or more layers that you can't connect to, or even worse, the entire geodatabase will throw a "Can not connect to database" error.

Fortunately I have found a solution that may allow you to recover it.  When ArcGIS compacts a geodatabase it renames the files it's currently working on *tmp.* as it rebuilds the layer then deletes the *tmp.* files when it's done.  Well that's how I think it's supposed to happen (this is all speculation on my part).  Apparently for reasons unknown, ArcGIS will rename the files and then just stop.  There aren't any error messages thrown, and ArcGIS will return a successful result.  You won't know there's a problem until the next time you try to access that data.

If this is the cause of your troubles, there are two things you can try. (make a complete copy of your file geodatabase before trying anything.  As always your mileage may vary.)

Method 1:
  Look for files that are named *tmp.*  They usually come in sets
(ex: a00000009tmp.freelist
      a00000009tmp.gdbtable
      a00000009tmp.gdbtablx)  . 

Rename them without the tmp:
     a00000009.freelist
     a00000009.gdbtable
     a00000009.gdbtablx

If there's already a file with one of those names (for example  a00000009tmp.freelist &  a00000009.freelist).  Keep the _renamed_ file deleting the existing file.

With any luck you should now be able to access your geodatabase layer.

Method 2:
Sometimes, that won't work.  In that case, create a new file geodatabase and copy all of the files except for  "gdb" and "timestamps" from the old geodatabase folder to the new geodatabase folder (using File Explorer or similar filesystem tool).  Proceed as in method 1 above.

I'm not sure why File Geodatabases are so fragile, so under documented, and without an official "Repair File Geodatabase" tool.  Hopefully this might allow you to recover an otherwise corrupt file geodatabase.

Outcomes