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 OD_Backup.sh 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/OD_Backup.sh
sudo chmod 750 /usr/local/bin/OD_Backup.shIn 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
In this folder (create it if it does not exist) /usr/local/bin/ make a text file called OD_Backup.sh 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/OD_Backup.sh
#!/bin/sh
#set -xv; exec 1>>/tmp/out 2>&1
path=/bin:/usr/bin:/sbin:/usr/sbin export PATHFILE="/tmp/sacommands.txt"
LOCATION="/Volumes/dbackup/ODM_backup/`date +%Y_%m_%d`"
LOGS="/tmp/logs.txt"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: your@email.here" > $LOGS
echo "From: Server Daily Report <your@email.here>" >> $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 your@email.here -t
rm -rf $FILE
rm -rf $LOGS
cntr-x cntr-c#set -xv; exec 1>>/tmp/out 2>&1
path=/bin:/usr/bin:/sbin:/usr/sbin export PATHFILE="/tmp/sacommands.txt"
LOCATION="/Volumes/dbackup/ODM_backup/`date +%Y_%m_%d`"
LOGS="/tmp/logs.txt"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: your@email.here" > $LOGS
echo "From: Server Daily Report <your@email.here>" >> $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 your@email.here -t
rm -rf $FILE
rm -rf $LOGS
sudo chmod 750 /usr/local/bin/OD_Backup.shIn 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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>int.***.OD.backup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/OD_Backup.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>2</integer>
<key>Minute</key>
<integer>5</integer>
</dict>
</dict>
</plist>
cntr-x cntr-cTo start your script use this command.sudo launchctl load -w /Library/LaunchDaemons/int.***.OD_Backup.plistThis is based on other people's input that I have gathered over the years.<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>int.***.OD.backup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/OD_Backup.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>2</integer>
<key>Minute</key>
<integer>5</integer>
</dict>
</dict>
</plist>