-
Notifications
You must be signed in to change notification settings - Fork 4
/
ldap-backup
executable file
·48 lines (48 loc) · 1.96 KB
/
ldap-backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#
# title :ldap-backup
# description :Perform LDAP backup on Zarafa server
# author :Alexander Jackson - Jackson IT
# date :20141017
# version :0.1
# usage :ldap-backup
# notes :Save in /usr/local/sbin/ chown: root.root chmod: 500
# bash_version :GNU bash, Version 4.2.37(1)-release (x86_64-pc-linux-gnu)
#
# Copyright 2014, Alexander Jackson <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at <http://www.gnu.org/licenses/> for
# more details.
#
#==============================================================================
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
BACKUP_PATH=/var/backups/ldap/${TIMESTAMP}
echo
echo + - - - LDAP-BACKUP ---------------------------------------------- - - - +
echo
echo " Creating backup at ${BACKUP_PATH}"
mkdir -p ${BACKUP_PATH}
/usr/bin/nice /usr/sbin/slapcat -n 0 > ${BACKUP_PATH}/config.ldif
/usr/bin/nice /usr/sbin/slapcat -n 1 > ${BACKUP_PATH}/domain.ldif
#/usr/bin/nice /usr/sbin/slapcat -n 2 > ${BACKUP_PATH}/access.ldif
chmod 640 ${BACKUP_PATH}/*.ldif
tar cpzf ${BACKUP_PATH}/etc_ldap.tgz /etc/ldap >/dev/null 2>&1
tar cpzf ${BACKUP_PATH}/var_lib_ldap.tgz /var/lib/ldap >/dev/null 2>&1
echo
echo + - - - CREATED FILES -------------------------------------------- - - - +
echo
ls -ahl ${BACKUP_PATH}
echo
echo + - - - INFO ----------------------------------------------------- - - - +
echo
echo " Run ldap-restore to restore previous backups..."
echo
echo + - - - ----------------------------------------------------- DONE - - - +