Fixes to ldap_restore script
This commit is contained in:
parent
5068c903fe
commit
016fedfacf
11
ldap_restore
11
ldap_restore
@ -7,17 +7,24 @@ assert "Unable to restore backup. Missing /var/backups/ldap/0.ldif backup of cn=
|
|||||||
[[ -f /var/backups/ldap/1.ldif ]]
|
[[ -f /var/backups/ldap/1.ldif ]]
|
||||||
assert "Unable to restore backup. Missing /var/backups/ldap/1.ldif backup of first database."
|
assert "Unable to restore backup. Missing /var/backups/ldap/1.ldif backup of first database."
|
||||||
|
|
||||||
|
[[ -n "${LDAP_DOMAIN}" ]]
|
||||||
|
assert "FATAL: Please set LDAP_DOMAIN and retry."
|
||||||
|
DN0="dc=${LDAP_DOMAIN//./,dc=}"
|
||||||
|
LDAP_DOMAIN_DN=${LDAP_DOMAIN_DN:=${DN0}}
|
||||||
|
|
||||||
# Backup and clean existing config directory
|
# Backup and clean existing config directory
|
||||||
tar czf /var/backups/ldap/etc_ldap_slapd_d-$(date '+%Y-%m-%d').tar.gz /etc/ldap/slapd.d
|
tar czf /var/backups/ldap/etc_ldap_slapd_d-$(date '+%Y-%m-%d').tar.gz /etc/ldap/slapd.d
|
||||||
assert "FATAL: could not backup /etc/ldap/slapd.d before restoring."
|
assert "FATAL: could not backup /etc/ldap/slapd.d before restoring."
|
||||||
find /etc/ldap/slapd.d -delete
|
find /etc/ldap/slapd.d -mindepth 1 -delete
|
||||||
assert "FATAL: could not clean /etc/ldap/slapd.d before restoring."
|
assert "FATAL: could not clean /etc/ldap/slapd.d before restoring."
|
||||||
|
|
||||||
# Backup and clean existing data directory
|
# Backup and clean existing data directory
|
||||||
tar czf /var/backups/ldap/var_lib_ldap-$(date '+%Y-%m-%d').tar.gz /var/lib/ldap
|
tar czf /var/backups/ldap/var_lib_ldap-$(date '+%Y-%m-%d').tar.gz /var/lib/ldap
|
||||||
assert "FATAL: could not backup /var/lib/ldap before restoring."
|
assert "FATAL: could not backup /var/lib/ldap before restoring."
|
||||||
find /var/lib/ldap -delete
|
find /var/lib/ldap -mindepth 1 -delete
|
||||||
assert "FATAL: could not clean /var/lib/ldap before restoring."
|
assert "FATAL: could not clean /var/lib/ldap before restoring."
|
||||||
|
mkdir "/var/lib/ldap/${LDAP_DOMAIN_DN}"
|
||||||
|
assert "FATAL: could not create /var/lib/ldap/${LDAP_DOMAIN_DN}."
|
||||||
|
|
||||||
# Restore cn=config
|
# Restore cn=config
|
||||||
echo "Restoring cn=config..."
|
echo "Restoring cn=config..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user