Skip to content

Instantly share code, notes, and snippets.

@holly
Created May 7, 2016 08:50
Show Gist options
  • Select an option

  • Save holly/6fa71edb6416b2d6f4846b42883b0d18 to your computer and use it in GitHub Desktop.

Select an option

Save holly/6fa71edb6416b2d6f4846b42883b0d18 to your computer and use it in GitHub Desktop.
#!/bin/bash
BACKUP_DIR=/backup/openldap
ROTATE=7
if [ ! -d $BACKUP_DIR ]; then
mkdir -p $BACKUP_DIR
fi
day=$(date '+%Y%m%d')
slapcat -b cn=config | gzip -c >$BACKUP_DIR/openldap-config-$day.ldif.gz
slapcat | gzip -c >$BACKUP_DIR/openldap-$day.ldif.gz
find $BACKUP_DIR -type f -mtime +$(($ROTATE - 1)) | xargs rm -vf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment