#!/bin/bash TIMESTAMP=$(date +%Y%m%d-%H%M%S) BACKUP_ROOT_LDAP=/backup/ldap BACKUP_PATH_LDAP=${BACKUP_ROOT_LDAP}/${TIMESTAMP} BACKUP_LDAP_RETENTION=10 # Let's go ! echo "Starting ldap backup process ..." # Backup server configuration mkdir -p ${BACKUP_PATH_LDAP} /usr/bin/nice /usr/sbin/slapcat -n 0 > ${BACKUP_PATH_LDAP}/config.ldif /usr/bin/nice /usr/sbin/slapcat -n 1 > ${BACKUP_PATH_LDAP}/domain.ldif chmod 640 ${BACKUP_PATH_LDAP}/*.ldif tar cpzf ${BACKUP_PATH_LDAP}/etc_ldap.tgz /etc/ldap >/dev/null 2>&1 tar cpzf ${BACKUP_PATH_LDAP}/var_lib_ldap.tgz /var/lib/ldap >/dev/null 2>&1 HOUR=`date +%Y%m%d%H%M` tar czf ${BACKUP_ROOT_LDAP}/ldap_${HOUR}.tar.gz ${BACKUP_PATH_LDAP} && rm -rf ${BACKUP_PATH_LDAP} # Purge old backup echo "Starting ldap purge process for backup older than ${BACKUP_PRODUCTS_RETENTION} ..." find ${BACKUP_ROOT_LDAP} -type f -mtime +${BACKUP_LDAP_RETENTION} -exec rm -f {} \;