Phabricator only interacts with Git repositories by running
git commands (and a handful of other “definitely safe” things like writing commit hook files), so nothing we do should be able to damage the repository in a way that it isn’t otherwise susceptible to (for example, we never directly modify files in the repository ourselves). So, if you can find guidance about similar cases in general, it may be helpful here: there’s no particular reason to believe that Phabricator does anything to make them more likely to be impacted by a power outage.
The expected structure of these directories (like
/var/repo/161/) is that they contain a bare Git repo like this:
/var/repo/12345/ $ ls -alh
drwxr-xr-x 12 epriestley staff 384B Sep 20 11:35 .
drwxr-xr-x 18 epriestley staff 576B Sep 1 13:05 ..
-rw-r--r-- 1 epriestley staff 204B Sep 17 13:30 FETCH_HEAD
-rw-r--r-- 1 epriestley staff 23B Sep 20 11:35 HEAD
drwxr-xr-x 2 epriestley staff 64B Sep 1 12:08 branches
-rw-r--r-- 1 epriestley staff 262B Sep 20 11:35 config
-rw-r--r-- 1 epriestley staff 73B Sep 1 12:08 description
drwxr-xr-x 13 epriestley staff 416B Sep 1 12:08 hooks
drwxr-xr-x 4 epriestley staff 128B Sep 1 12:12 info
drwxr-xr-x 92 epriestley staff 2.9K Sep 17 13:30 objects
-rw-r--r-- 1 epriestley staff 366B Sep 1 12:09 packed-refs
drwxr-xr-x 4 epriestley staff 128B Sep 1 12:08 refs
What’s in them now? Do they look like this, or are they totally empty?
If they’re fully gone or you run out of ways to try to restore them to a working state, you can (mostly) restore them like this:
- Stop the daemons.
- Put the best clone you can find (e.g., from a developer’s laptop) on disk somewhere.
mv 123 123.old to move aside the bad/damaged repository.
git clone --bare file:///path/to/developer/working-copy 123 to clone a new bare working copy.
- (Once you’ve restored everything, start the daemons again.)
Depending on what the developer had this may not get 100% of everything back (e.g., some branches or tags may be missing or out of date), but should get you most of the way without needing too much init + push fiddling.