/etc/periodic/daily
, the system cron jobs will run it automatically for you when they do the other system maintenance jobs. Don't forget to chmod +x it once you're done editing the script.You can download the script from here.
#! /bin/bash
#
# Usage: put this into /etc/periodic/daily as something like 800.backup_LDAP
# and the stock Apple cron jobs will run it automatically every day.
#
# Copyright 2004 J. P. Block
#
# This is released under the BSD license, but please send me any
# modifications so I can update the released version.
source /sw/bin/init.sh
# how many days we keep backups for
DAYLIMIT=30
STAMP=`date +%Y-%m-%d-%H%M%S`
DESTDIR=/usr/local/backups/OSXServerDirectoryService
# ensure the destination exists
mkdir -p $DESTDIR
tar cvf $DESTDIR/DirectoryService_$STAMP.tar /Library/Preferences/DirectoryService
gzip -9v $DESTDIR/DirectoryService_$STAMP.tar
chmod 400 $DESTDIR/DirectoryService_$STAMP.tar.gz
# backup LDAP
/usr/sbin/slapcat -l $DESTDIR/slapcat_$STAMP.ldif -f /etc/openldap/slapd.conf
gzip -9v $DESTDIR/slapcat_$STAMP.ldif
# Backup password server
mkdir -p $DESTDIR/mkpassdb
mkpassdb -backupdb $DESTDIR/mkpassdb
tar cvf $DESTDIR/passdb_$STAMP.tar $DESTDIR/mkpassdb
gzip -9v $DESTDIR/passdb_$STAMP.tar
rm -fr $DESTDIR/mkpassdb
find $DESTDIR -mtime +$DAYLIMIT -exec rm '{}' ';'
No comments:
Post a Comment