server-tools !?!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 line
907 B

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