Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment

Open Directory Backups Fail Due To HostName Problems

If you don’t have a HostName set on your computer then Open Directory backups are likely to fail using Time Machine. How did you promote to an Open Directory Master if you don’t have functional backups you may ask? Let’s not worry about that for now. Instead, let’s turn our attention to /var/backups. You see, if you enable Time Machine on an OS X Server, you’ll get a ServerBackup_OpenDirectoryMaster.sparseimage in that folder, which contains your Open Directory backups and gets picked up by our pal Time Machine.

You can manually run a backup using the opendirectorybackup script at /Applications/Server.app/Contents/ServerRoot/usr/libexec/server_backup/opendirectorybackup. This could be automated, using expect to send a password, but for now, we’ll run it manually and get this error while running:

2013-09-27 19:13:23 +0000 Error in backing up computer password -25300
2013-09-27 19:13:23 +0000 Error: Unable to create archive image as keychain could not be read
2013-09-27 19:13:23 +0000 Removed directory at path /tmp/slapconfig_backup_stage86725oncD7u.
2013-09-27 19:13:23 +0000 Removed file at path /var/run/slapconfig.lock.

The error doesn’t exactly tell us why the backup isn’t completing, but the actual problem is that our hostname is broken. Run hostname and it doesn’t appear that way, though:

hostname

But if you run scutil to get the hostname it is empty:

scutil --get HostName

To set it properly, let’s run scutil with the –set option and configure the hostname as phil.mynetwork.lan:

scutil --set HostName phil.mynetwork.lan

This also causes replication to fail in many cases. You might also have to delete the My com.apple.opendirectory entry in your keychain in order for automated tasks to get working again.