yunohost/data/hooks/backup/05-conf_ldap
Jérôme Lebleu 141d704a04 [fix] Review LDAP backup and restore hooks
The configuration is now saved using slapcat instead of trying to generate
it from slapd.conf - which generally fail at restoration.
Also, a backup of configuration and database is made before the restoration,
which allows to return to a "working" state if it fails.
2016-01-23 19:15:13 +01:00

16 lines
527 B
Bash

#!/bin/bash
backup_dir="${1}/conf/ldap"
sudo mkdir -p "$backup_dir"
# Fix for first jessie yunohost where slapd.conf is called slapd-yuno.conf
# without slapcat doesn't work
[[ ! -f /etc/ldap/slapd.conf ]] \
&& sudo mv /etc/ldap/slapd-yuno.conf /etc/ldap/slapd.conf
# Back up the configuration
sudo cp -a /etc/ldap/slapd.conf "${backup_dir}/slapd.conf"
sudo slapcat -b cn=config -l "${backup_dir}/cn=config.master.ldif"
# Back up the database
sudo slapcat -b dc=yunohost,dc=org -l "${backup_dir}/dc=yunohost-dc=org.ldif"