Recovering NetInfo Domains from Backup:
-------------------------------------------
<<Good News: the database can be backed up -- in fact, if you leave your computer on overnight, it'll get backed up automatically every night.
Bad News: the backup is in a different format (nidump's "raw" format which is completely different from nicl -raw) than the live database, and Apple hasn't (as far as I can find, anyway) provided a simple way to recover the backup on a hosed system.
Good News: it can be done. Here's the procedure:
1. Boot the computer into single-user mode by holding down Command-S as it begins to boot. It'll spew some information about the boot sequence, then drop you into a command line. At this point, the system is only partly started -- most important for our purposes, NetInfo hasn't been started yet. But also a lot of other things haven't been done that'll need to be taken care of by hand, like getting the boot disk checked and mounted for write access.
2. Use the command "fsck -y" to check the integrity of the boot disk's file structure. If it makes any repairs (it'll print "***** FILE SYSTEM WAS MODIFIED *****"), run it again. Keep running it until it stops finding problems.
3. Use the command "mount -uw /" to remount the boot disk with write access enabled.
4. "ls -l /var/backups" this prints a list of everything in the backups directory. It should respond with something like:
total 40
-rw-r--r-- 1 root wheel 19001 Aug 4 03:15 local.nidump
The date on the file (in this case "Aug 4 03:15") indicates when the backup was made. If it's not from a time when the computer was working right, or if the response doesn't list a file named "local.nidump" (e.g. if it simply gives you the localhost# prompt without printing anything first), you don't have an appropriate backup, and these instructions won't work for your situation. Sorry.
5. "cd /var/db/netinfo" this gets us to the directory where the live NetInfo databases are kept.
6. "mv local.nidb local.nibad" inactivate the damaged database by giving it an invalid name.
7. "nicl -raw local.nidb -create" build a nice clean (empty) replacement database in its place.
8. "nicl -raw local.nidb -create /users/root uid 0" for one of the later steps, we need the root user to exist in NetInfo, so create it now.
9. "SystemStarter" start up more of the system, including the NetInfo and lookupd infrastructure.
Note: on Mac OS versions 10.1.1 and 10.1.2 there appears to be a bug that prevents SystemStarter from operating properly. See below for a workaround.
10. "niload -r / . </var/backups/local.nidump" load the contents of the backup into the new (live) database.
Notes: be careful to use "<", not ">". ">" will erase your backup file. Also, be patient; it can take a minute to rebuild the entire database. But if it takes more than 10 minutes or so, something probably went wrong, and you may need to start over.
11. "reboot" restart the system, this time in a more normal fashion.
12. If all goes well, you can now delete the damaged NetInfo database, /var/db/netinfo/local.nibad (or whatever you renamed it to). If not, or if you don't trust the rebuilt database, hang onto it; you can always switch back to it if necessary.
------------------------------------------------------------------------
Manually starting NetInfo under Mac OS X 10.1.1-.2
The SystemStarter command doesn't seem to work under Mac OS X version 10.1.1-.2; you can start the relevant system components using the commands:
1. "/System/Library/StartupItems/Network/Network"
2. "/System/Library/StartupItems/DirectoryServices/DirectoryServices"
Then proceed to the niload step.>>
-----------------------------------------------
Good luck.
Cheers...