Thursday, April 17 2003
Restoring a NetInfo domain
Last friday I upgraded a few machines to 10.2.5. One of the upgrades failed miserably and did so while writing /usr/lib/libSystem.B.dylib; the machine was rendered useless. We had for a long time been thinking of switching to newer hardware and I saw the crash as an opportunity to do just that.
After the OS was installed on the new machine and all updates applied I moved over the disk from the old server. Next step was to restore parts of the NetInfo database, namely user and group information. The new NetInfo administration tool (command line version) is called nicl and can work in raw mode, i.e. directly manipulate a database file. This is a great enhancement over the old tools (nidump and niload) that only work on live databases. I encountered one problem though: nicl apparently has no facilities to dump a database to flat-file the way nidump does.
Fortunately the local NetInfo domain is backed up every night using nidump, so all I had to do was copy the relevant user and group data from that dump and paste it into a dump made on the new system. A simple niload the merged data and the machine was essentially up and running again.
Lessons learned: first off, Software Update can be dangerous as it simply un-pax the data directly to its destination. This particular crash might have been avoided if the installer would first unpack the new file to a temporary name, then renam() it. Perhaps. Second, Google is your friend: I knew the NetInfo database was backed up nightly, but Google make me realize the backup was actually a dump, not the database itself. And lastly, I'll submit an enhancement request to Apple asking for a dump command in nicl. That'd be nice.
