#!/bin/bash # Path to the root folder where the backups will be stored # This path should not be on the root volume, and not accessible # to non-administrators recover_path="/path/to/backup" # You can either backup all of the services (even those not in use) # or you can specify which services you want to backup. services=`serveradmin list` #services="afp ipfilter smb" # This is the password you will use to recover your OD sparseimage. # It should NOT be the same as your Directory Administrator password # for security reasons. passwd="cr38aNuPassWd" ############################################################### #### Advanced modification only. The rest can be left as is ### ############################################################### # This is the hostname of the server the script is running on # This variable is used so that the same script can be run # from multiple servers on a single share point server=`hostname` # Get today's date and format it as YYYYMMDD date=`date ''+%c%m%d'' | awk '{printf $5}'` # Set the full path to where this days backups will be stored recover=${recover_path}/$server/$date mkdir -p $recover chmod 600 $recover # grab the server configuration plists for service in $services; do serveradmin -x settings $service > $recover/$service.plist sleep 1 done # Backup Open Directory od_backup=$recover/od_backup ts=`date ''+%F''` echo "dirserv:backupArchiveParams:archivePassword = $passwd" > $od_backup echo "dirserv:backupArchiveParams:archivePath = $recover/od_$ts" >> $od_backup echo "dirserv:command = backupArchive" >> $od_backup echo "" >> $od_backup serveradmin command < $od_backup exit 0