Years ago I put together the following expect
script to perform Open Directory backups under Tiger Server and it's worked well under Leopard Server as well:
#!/usr/bin/expect -f
set date [timestamp -format "%Y-%m-%d"]
set archive_path "path/to/you/backup/dir"
set archive_password "password"
set archive_name "opendirectory_backup"
spawn /usr/sbin/slapconfig -backupdb $archive_path/$archive_name-$date
expect "Enter archive password"
send "$archive_password\r"
expect eof
It's one of the few scripts that still lives in root's crontab as opposed to having a launchd
plist. It's rwx
by root only for obvious security reasons.
Now, the problem is I upgraded my Open Directory Master to Mac OS X 10.6.4 Snow Leopard Server a couple weeks ago and it hasn't worked since... when run by cron. If I log in as the root user and run it manually it works correctly and creates the resulting encrypted disk image. When run by cron, it goes through the full motions (incl. output in /Library/Logs/slapconfig.log
that matches that of when it's run manually), but the disk image file is never created. However, in `/var/log/system.log/ I see the following output:
Jul 23 03:00:08 servername hdiejectd[93114]: running
Jul 23 03:00:11 servername diskimages-helper[93111]: -frameworkCallbackWithDictionary: threw exception calling home.
Jul 23 03:00:11 servername diskimages-helper[93111]: threw exception reporting results back to framework.
Jul 23 03:00:21 servername hdiejectd[93114]: quitCheck: calling exit(0)
When run manually, that output is as follows (no diskimages-helper
exceptions):
Jul 23 14:29:27 servername hdiejectd[7776]: running
Jul 23 14:29:40 servername hdiejectd[7776]: quitCheck: calling exit(0)
In both cases there is no user logged in via the GUI. I have a couple friends who're running the same script on their OD Masters and it also no longer runs via cron since upgrading to Snow Leopard Server.
I recall some issues with Mac OS X's command line disk image tools that required keychain access, but I don't recall the specifics. Did something related to that get more strict in Snow Leopard Server?
Any ideas or suggestions?