Open Directory Backup Script

Here are the instructions for creating a backup of your Open Directory Server.
In this folder (create it if it does not exist) /usr/local/bin/  make a text file called with the following content. Make sure you point the LOCATION to another drive, change the password, and email addresses.

sudo mkdir -p /usr/local/bin
sudo emacs /usr/local/bin/
#set -xv; exec 1>>/tmp/out 2>&1
path=/bin:/usr/bin:/sbin:/usr/sbin export PATH

LOCATION="/Volumes/dbackup/ODM_backup/`date +%Y_%m_%d`"

mkdir -p /Volumes/dbackup/ODM_backup
find /Volumes/dbackup/ODM_backup* -mtime +6 -exec rm -rf {} \;
echo "dirserv:command = backupArchive" > $FILE
echo "dirserv:backupArchiveParams:archivePassword = *******" >> $FILE
echo "dirserv:backupArchiveParams:archivePath = /Volumes/dbackup/ODM_backup/`date +%Y_%m_%d`" >> $FILE
serveradmin command < $FILE
echo "To:" > $LOGS
echo "From: Server Daily Report <>" >> $LOGS
echo "Subject: Daily ODM Backup Report" - `data` >> $LOGS
echo "The Open Directory Master at `hostname` has been successfully backed up. It's location is $LOCATION and will be available for seven days. After seven days, the archive will be deleted." >> $LOGS
cat $LOGS | sendmail -f -t
rm -rf $FILE
rm -rf $LOGS
cntr-x cntr-c
sudo chmod 750 /usr/local/bin/

In this directory /Library/LaunchDaemons/ create a file called int.***.OD_Backup.plist where *** is some internal characters, probably dcs. Into that file place the following contents, changing *** whereever you see it.

sudo emacs /Library/LaunchDaemons/int.***.OD_Backup.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
cntr-x cntr-c

To start your script use this command.

sudo launchctl load -w /Library/LaunchDaemons/int.***.OD_Backup.plist

This is based on other people's input that I have gathered over the years.