]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Adding function do_ldap_backup
authorFrank Brehm <frank@brehm-online.com>
Sun, 16 May 2021 20:56:54 +0000 (22:56 +0200)
committerFrank Brehm <frank@brehm-online.com>
Sun, 16 May 2021 20:56:54 +0000 (22:56 +0200)
bin/manual-backup

index bedff591a56df53fa694ed77b08b6b5ea4b83163..f0cad29a59f643d2c443232df5a794f808bc3c14 100755 (executable)
@@ -248,6 +248,12 @@ do_dir_backup() {
     cd /
     dir_backup "etc" "etc"
     dir_backup "root" "root"
+    if [[ -d "opt/fbrehm" ]] ; then
+        dir_backup "opt/fbrehm" "opt-fbrehm"
+    fi
+    if [[ -d "var/bind" ]] ; then
+        dir_backup "var/bind" "var-bind"
+    fi
     dir_backup "var/lib" "var-lib"
     dir_backup "var/log" "var-log"
     dir_backup "var/spool/cron" "var-spool-cron"
@@ -388,6 +394,42 @@ do_postgres_backup() {
 
 }
 
+#------------------------------------------------------------------------------
+do_backup_ldap() {
+
+    local dumpfile="${BACKUP_DIR}/ldap.dump.ldif.gz"
+
+    if ps -ef | grep slapd | grep -v grep >/dev/null ; then
+        :
+    else
+        debug "OpenLDAP Server is not running."
+        return
+    fi
+
+    empty_line
+    info "Dumping OpenLDAP Datenbank -> '${CYAN}${dumpfile}${NORMAL}' ..."
+
+    local cmd="ldapsearch -D \"${LDAP_DN}\" -x -h localhost"
+    if [[ "${VERBOSE}" == "y" ]] ; then
+        cmd+=" --verbose"
+    fi
+    cmd+=" -z 10000 -w \"${LDAP_PW}\" -b \"${LDAP_SEARCH_BASE}\""
+    cmd+=" | gzip -9"
+    if [[ "${VERBOSE}" == "y" ]] ; then
+        cmd+=" --verbose"
+    fi
+    cmd+=" > \"${dumpfile}\""
+    if [[ "${SIMULATE}" == "y" ]] ; then
+        info "Executing: ${cmd}"
+        return
+    fi
+    debug "Executing: ${cmd}"
+    eval ${cmd}
+    debug "Finished LDAP dump."
+
+}
+
+
 #------------------------------------------------------------------------------
 create_checksums() {
 
@@ -513,6 +555,7 @@ main() {
     if [[ "${DO_POSTGRES}" == "y" ]] ; then
         do_postgres_backup
     fi
+    do_backup_ldap
     create_checksums
     clean_old_backups
     sync_to_remote