Automatic eDirectory Backup on SLES with ICE
This article describes how to get an LDIF file using ICE from a script launched by Cron, and receive an email of the output.
What you need is:
- “ICE” package (my version is novell-NOVLice-8.8.1-7.i386.rpm). The package is available in the Setup directory of the eDirectory source installation CD.
- A local (server) Linux user that will run the script in its crontab
- The modified script to handle your servers, users, and tree references
- Smtp relay host information
Installation
1. Install the ICE package:
myserver:/home/rvi/mountTMP/setup # rpm -ivh novell-NOVLice-8.8.1-7.i386.rpm Preparing... ########################################### [100%] 1:novell-NOVLice ########################################### [100%] myserver:/home/rvi/mountTMP/setup #
2. Create a directory where you will put your LDIF output. For this example, “backup” directory is created in /opt/novell/eDirectory.
myserver:/opt/novell/eDirectory # md backup
The script will create the LDIF file, compress it, and manage its history.
3. Define “Myxxxx” variables and check System Variables.
#!/bin/bash ##FULL EDIRECTORY backup via Ice ##System Variables: Wdir=/opt/novell/eDirectory/backup CDate=`date +%Y%m%d` FLdif=Ldif-$CDate.ldif Flog=Icelog-$CDate.log IceDir=/opt/novell/eDirectory/bin ##Define your environment variable: Mytree="TESTTREE" MySrv="10.120.130.140" MyUser="cn=bck,ou=system,o=otest" MyPwd="bckPwd" cd $Wdir $IceDir/ice -l$Flog -SLDAP -s$MySrv -p389 -d$MyUser -w$MyPwd -csub -Fobjectclass=* -DLDIF -f$FLdif ## Compress ldif and log Files gzip $FLdif gzip $Flog ##Remove Files older than 7 days find /opt/novell/eDirectory/backup -name 'Icelog-*' -mtime +7 -exec rm {} \; find /opt/novell/eDirectory/backup -name 'Ldif*' -mtime +7 -exec rm {} \;
4. Modify access rights for the script to restrict the access to all but the owner of the file.
myserver:/opt/novell/eDirectory # chmod 700 IceCron.sh
Configure the Crontab of your local Linux user to launch the script. The examples below will launch the scripts at 18h30, from Monday to Friday:
myserver:/opt/novell/eDirectory # crontab -e 30 18 * * 1,2,3,4,5 sh /opt/novell/eDirectory/backup/IceCron.sh
5. To receive an email of the ICE output, add your email address at the beginning of crontab -e:
MAILTO=adminsupport@mycompany.com
Example:
MAILTO=adminuser@mycompany.com #MAILTO=root 30 18 * * 1,2,3,4,5 sh /opt/novell/eDirectory/backup/IceCron.sh
6. Modify the SMTP relay host of the local Linux server to send email outside of the local machine. First, modify in “/etc/postfix/main.cf”:
relayhost = mysmtpserver.mycompany.com
and then modify in “/etc/sysconfig/postfix”:
POSTFIX_RELAYHOST="mysmtpserver.mycompany.com"
Result
Here i sth output of ICE-Cron received by e-mail:
Novell Import Convert Export utility for Novell eDirectory version: 20112.86 Copyright 2000-2005 Novell, Inc. All rights reserved. U.S. Patent No. 6,915,287. Source Handler: ICE LDAP handler for Novell eDirectory (version: 20112.86 ) Destination Handler: ICE LDIF handler for Novell eDirectory (version: 20112.86 ) ICE log file: /opt/novell/eDirectory/backup/Icelog-2008-01-11-19:00:01.log Start time: Fri Jan 11 19:00:01 2008 Press control-C to exit Operation in progress ... . . . . . . . . . 1000 Records Processed . . . . . . . . . 2000 Records Processed . . . . . . . . . 3000 Records Processed . . . . . . . . Total entries processed: 3829 Total entries failed: 0 End time: Fri Jan 11 19:00:20 2008 Total Time: 0:00:20.008 Time per entry: 00:00.005
No comments yet