Recovering OS X Open Directory from Backup

July 24, 2012 Brian Cunnie

Lost Open Directory Database

You’ve lost your Open Directory server database. You need to recover it, but you don’t have an Open Directory Archive, and you don’t have a replica that you can promote. And you don’t want to restore the entire server, either.

This blog post covers how to restore an Open Directory database from backup.


This blog post is directed towards system administrators

  • who have an Open Directory Server that is running OS X Snow Leopard 10.6.8 (this procedure would probably run under other versions of Snow Leopard, but we haven’t tested it)
  • who do not have a replica that they can promote
  • who do not have a conventional Open Directory backup (i.e. Server Admin → Open Directory → Archive)
  • who want to do a surgical restore of just the Open Directory; who do not want to touch the other parts of the system
  • who have backed up their files.


This procedure worked for us; it may not work for you. YMMV. There is no warranty, express or implied. This is by no means an Apple-approved procedure.

Open Directory

Open Directory is a tightly integrated application that includes OpenLDAP, kerberos, and Apple’s password service. For a successful recovery, you need to restore the records for all 3 services.


Your Open Directory Server needs to be configured as a server (not replica). If it’s configured as a replica, re-configure it as a standalone server before you begin.

First, shut down the relevant daemons (slapd/OpenLDAP, kerberos, Password Service).

sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist
sudo launchctl unload /System/Library/LaunchDaemons/
sudo launchctl unload /System/Library/LaunchDaemons/
sudo launchctl unload /System/Library/LaunchDaemons/

Check to make sure the processes aren’t running (we’re being very careful, maybe even paranoid):

ps auxwww | egrep "slapd|kadmin|krb5|Pass"

Move the old files out of the way:

sudo mv -i /var/db/openldap{,-broke}
sudo mv -i /var/db/krb5kdc{,-broke}
sudo mv -i /var/db/authserver{,-broke}
sudo mv -i /etc/krb5.keytab{,-broke}
sudo mv -i /Library/Preferences/{,-broke}

Restore the files from backup (your backup directory, e.g. “/Volumes/Backup/yesterday”, may differ):

sudo rsync -avH /Volumes/Backup/yesterday/private/var/db/openldap /var/db/
sudo rsync -avH /Volumes/Backup/yesterday/private/var/db/krb5kdc /var/db/
sudo rsync -avH /Volumes/Backup/yesterday/private/var/db/authserver /var/db/
sudo rsync -avH /Volumes/Backup/yesterday/private/etc/krb5.keytab /etc/
sudo rsync -avH /Volumes/Backup/yesterday/Library/Preferences/ /Library/Preferences/

Double-check that they’re in place (yes, paranoia again):

sudo ls -l /var/db/{krb5kdc,openldap,authserver} /etc/krb5.keytab /Library/Preferences/

Reboot the machine:

sudo shutdown -r now

When the machine comes up, you should have recovered your Open Directory database to the same state as it was when you performed your backup.

Good luck.

About the Author


Kumi Walker – Stackmob
Kumi Walker – Stackmob

… Read more

Unicycle Butter sandwich
Unicycle Butter sandwich

Helps jasmine:ci not closing chrome windows?

SpringOne 2021

Register Now