There are some serious security issues that users of these scripts should be made aware of.
Plaintext account, wifi, and other passwords will appear in the .sql dump file. It it necessary to take precautions to encrypt and protect these backup files.
Here's a suggested modification that will gpg-encrypt the compressed .sql file, and also backup Open Directory, serveradmin settings, and other PostgreSQL tables.
#!/bin/bash
umask 077
OSX_SERVER_BACKUP=/private/var/backups/osx_server_backup
TS=`date ''+%F''`
ODBACKUP_PASSWD=protect-this-shell-script-too-because-it-has-the-plaintext-backup-passphrase
if [ ! -d "$OSX_SERVER_BACKUP" ]; then
mkdir -m 700 -p "$OSX_SERVER_BACKUP"
fi
# Remove archives older than one year
find $OSX_SERVER_BACKUP -mindepth 1 -mtime +365 -exec /bin/rm {} ';'
# Open Directory backup
/Applications/Server.app/Contents/ServerRoot/usr/libexec/server_backup/openDirectory_backup -cmd backup -log /private/var/log/server_backup/openDirectory_backup.log
# Open Directory backup backup
cat <dirserv:backupArchiveParams:archivePassword = $ODBACKUP_PASSWD
dirserv:backupArchiveParams:archivePath = $OSX_SERVER_BACKUP/od_$TS
dirserv:command = backupArchive
SERVERADMIN_ODBACKUP
# serveradmin configuration plist
sh -c "serveradmin -x settings all | bzip2 -c | gpg -o - -c --passphrase $ODBACKUP_PASSWD > $OSX_SERVER_BACKUP/serveradmin_$TS.plist.bz2.gpg"
chmod go-rwx $OSX_SERVER_BACKUP/serveradmin_$TS.plist.bz2.gpg
# Backup all tables
sh -c "/Applications/Server.app/Contents/ServerRoot/usr/bin/pg_dumpall -U _postgres | bzip2 -c | gpg -o - -c --passphrase $ODBACKUP_PASSWD > $OSX_SERVER_BACKUP/postgres_$TS.dumpall.bz2.gpg"
chmod go-rwx $OSX_SERVER_BACKUP/postgres_$TS.dumpall.bz2.gpg
# Backup Profile Manager
sh -c "pg_dump -h /Library/Server/ProfileManager/Config/var/PostgreSQL -U _devicemgr devicemgr_v2m0 -c | bzip2 -c | gpg -o - -c --passphrase $ODBACKUP_PASSWD > $OSX_SERVER_BACKUP/ProfileManager_$TS.dump.bz2.gpg"
chmod go-rwx $OSX_SERVER_BACKUP/ProfileManager_$TS.dump.bz2.gpg