Tool
by Brad Bartholomew
Here are two scripts for doing a backup of eDirectory on Linux using either dsbk or ndsbackup. Download the file and use the following instructions to implement.
Installation instructions:
- Copy the edirbkup.tgz file to the root directory '/'. Extract the backup directory and scripts by executing the following command:
# tar zxvf edirbkup.tgz
- Modify the scripts by changing the variables to be specific to your server and eDirectory tree.
# vi dsbkup.sh # vi ndsbackup.sh
- Add an entry in crontab to schedule the script to run automatically. To run nightly you may use something like this:
0 23 * * * /backup/dsbkup.sh 30 23 * * * /backup/ndsbackup.sh
The scripts are designed to keep only the 7 most current backups. You can modify it to meet your needs.
| Attachment | Size |
|---|---|
| edirbkup.zip | 1.61 KB |
Related Articles
User Comments
Nice article
Submitted by tokeeffefcc on 25 October 2011 - 5:41am.
I took these scripts and updated them for SLES10sp4 and above with eDir 8.8x
I am pasting them in below. I did add a couple of things like sending an email when completed.
One thing that I found was that you had to be very specific on your variables and your directory structure. Pay attention with the variables and don't forget to chmod the script to make them exectutable.
My updates also assume that you place these scripts in a new folder called \backup off the root, which is maintained secure on my systems.
I did this for security purposes. Jim Henderson also gave me some ideas that I incorporated into the scripts.
Now all you need to do is also backup the NICI and get a copy of the CA and you have a good backup of your eDirectory.
dsbkup.sh
#!/bin/bash
####################################################
# Name: dsbkup.sh
#
# Author: Brad Bartholomew, Novell
#
# Purpose: To perform full backups of eDirectory.
# To archive and zip the backups to be
# ready for tape archival.
#
# Change control:
# 1. 1/24/2007 - Created
# 2. 1/25/2007 - Modified to include deletion of
# files after being tarred.
# 3. 1/25/2007 - Added variables for ease of use
# when copying script to other
# servers.
# 4. 1/25/2007 - Added rolling log delete after
# seven days.
# 5. 5/21/2007 - Changed name to dsbkup.sh and
# modified to use dsbk instead of
# emtools.
# New fork
# 6. 2/15/2011 - Updated script for cleaning up
# self and portability
# 7. 10/04/2011 - Updated script for email notifications
####################################################
. /opt/novell/eDirectory/bin/ndspath
# Variables
CDate=`date +%Y%m%d`
tree=your_tree
server=your_server
file=$tree$server$CDate
backupdir="/var/opt/novell/eDirectory/backup"
EMAIL1=root
EMAIL2=name1@domain.com
EMAIL3=name2@domain.com
# Generate unique timestamp for each file name
timestamp="$(date +'%m-%d-%I:%M')" #get timestamp to use on files
echo "Timestamp = $timestamp"
# Backup eDirectory
echo " Starting backup of eDirectory on $server ..."
dsbk backup -b -f $backupdir/$tree/$file.bkup -l $backupdir/$tree/$file.log -t -w
# Check to see if backup is complete
sleep 10
i=`ls -l $backupdir/$tree/$file.bkup | cut -d' ' -f6`
sleep 10
i2=`ls -l $backupdir/$tree/$file.bkup | cut -d' ' -f6`
while [ $i -ne $i2 ]
do
sleep 60
i=`ls -l $backupdir/$tree/$file.bkup | cut -d' ' -f6`
sleep 10
i2=`ls -l $backupdir/$tree/$file.bkup | cut -d' ' -f6`
done
# Archive files
echo " Archiving $file ..."
tar zcvf $backupdir/$tree/$file.tgz $backupdir/$tree/$file.bkup $backupdir/$tree/$file.log
# Delete unnecessary files
echo " Deleting temp files ..."
rm -f $backupdir/$tree/$file.bkup $backupdir/$tree/$file.log
# Delete files older than 7 days, even though you use +5, might be something weird on my systems
echo " Deleting files older than 5 days ..."
find $backupdir/$tree/ -name '*.tgz' -mtime +5 >> /tmp/dsbackup.tmp
cat /tmp/dsbackup.tmp | while read delfil
do
rm -f ${delfil}
done
[[ -s /tmp/dsbackup.tmp ]] &echo " Backup script complete."
# Email notice of backup
echo "eDir dsBackup of $tree $server complete at $timestamp. Placed in $backupdir/$tree/$tree.$timestamp." | mail -s "eDir dsBackup report for $server" $EMAIL1,$EMAIL2,$EMAIL3
# End of Script
ndsbackup.sh
#!/bin/bash
#######################################################
# Name: ndsbackup.sh
#
# Author: Brad Bartholomew, Novell
#
# Purpose: To perform a backup of all the tree objects
# To zip the backups to be ready for the tape
# archival.
#
# Change control:
# 1. 1/24/2007 - Created
# 2. 1/25/2007 - Added variables for ease of use
# when copying script to other
# servers.
# 3. 1/25/2007 - Added rolling log delete after
# seven days.
# New fork
# 4. 2/15/2011 - Updated script for cleaning up
# self and portability
# 5. 10/04/2011 - Updated script for email notifications
#######################################################
. /opt/novell/eDirectory/bin/ndspath
# Variables
User=your_name.ou.o
Pwd=your_password
tree=your_tree
CDate=`date +%Y%m%d`
server=your_server
file=$tree$server$CDate
backupdir="/var/opt/novell/eDirectory/backup"
CDir=/etc/opt/novell/eDirectory/conf/nds.conf
JPath=/opt/novell/eDirectory/lib/nds-modules/embox/jre/bin
EMAIL1=root
EMAIL2=name1@domain.com
EMAIL3=name2@domain.com
# Generate unique timestamp for each file name
timestamp="$(date +'%m-%d-%I:%M')" #get timestamp to use on files
echo "Timestamp = $timestamp"
# Backup eDirectory
echo " Starting backup of eDirectory on $server ..."
ndsbackup cvf $backupdir/$tree/$file.bak --config-file $CDir -a $User -p $Pwd $tree
tar zcvf $backupdir/$tree/$file.tgz $backupdir/$tree/$file.bak
# Now lets backup the eDirectory schema
ndsbackup cvf $backupdir/$tree/$file.schema.bak $bserver -a $User -p $Pwd Schema >> $backupdir/$tree/logs/$file.schema.log
tar zcvf $backupdir/$tree/$file.schema.tgz $backupdir/$tree/$file.schema.bak
# Delete unnecessary files
echo " Deleting temp files ..."
rm -f $backupdir/$tree/*.bak
# Delete files older than 7 days , even though you use +5
echo " Deleting files older than 5 days ..."
find $backupdir/$tree/ -name '*.tgz' -mtime +5 >> /tmp/ndsbackup.tmp
cat /tmp/ndsbackup.tmp | while read delfil
do
rm ${delfil}
done
[[ -s /tmp/ndsbackup.tmp ]] &# Delete log files older than 7 days, even though you use +5, might be something weird on my systems
echo " Deleting log files older than 7 days ..."
find $backupdir/$tree/logs/ -name '*.log' -mtime +5 >> /tmp/ndsbackuplog.tmp
cat /tmp/ndsbackuplog.tmp | while read delfil
do
rm ${delfil}
done
[[ -s /tmp/ndsbackuplog.tmp ]] &echo " Backup script complete."
# Email notice of backup
echo "nds Backup of $tree $server complete at $timestamp. Placed in $backupdir/$tree/$tree.$timestamp." | mail -s "nds Backup report for $server" $EMAIL1,$EMAIL2,$EMAIL3
# End of Script
- Be the first to comment! To leave a comment you need to Login or Register


1