Sistemas‎ > ‎Linux‎ > ‎Scripts Linux‎ > ‎Ldap‎ > ‎

fazBackupLdap.sh

#!/bin/bash

# Backup
# /usr/sbin/slapcat -v -l /home/backup/ldap.ldif

# Restore
# /etc/init.d/slapd stop
# rm -rf /var/lib/ldap/*
# /usr/sbin/slapadd -l backup.ldif
# /etc/init.d/slapd start

# Reparar base corrompida
# db_recover -c -v -h /var/lib/ldap

mkdir /empresa/backup
rm -rf /empresa/backup/*.ldif
/usr/sbin/slapcat -l /empresa/backup/backupLdap_`date "+%Y%m%d-%H%M"`.ldif

mkdir /mnt/backup

# Montando particao
mount 192.168.2.25:/backup/sambaldap /mnt/backup/

tar cvfz /mnt/backup/backupLdap_`date "+%Y%m%d-%H%M"`.tar.gz /empresa/backup/*.ldif /etc/openldap/*.conf /var/lib/ldap/DB_CONFIG /etc/samba/*.conf /etc/smbldap-tools /etc/*.conf /etc/logrotate.d /emprsea

# Apagando arquivos antigos (mais de 2 dias).
find /mnt/backup/ -mtime +2 -exec rm -rf {} \;

# Desmontando particao
umount /mnt/backup

Comments