Application Delivery Management
Application Modernization & Connectivity
IT Operations Management
CyberRes
#!/bin/bash
# Backup Options:
#
# 'backup' Perform an eDirectory backup
# -b Performs a full backup of the eDirectory database.
# -f Specifies the path and file to back up to
# -l Specifies the log file for the back up
# -t Includes the stream files when backing up the eDirectory database.
# -w Overwrites the backup file specified with the -f switch if a file of the same name already exists.
# -e <pwd> Includes the NICI encryption keys using password <pwd>
TODO=backup
BACKUPTYPE=-b
BACKUPTO=-f
BACKUPLOG=-l
BACKUPSTREAMS=-t
OVERWRITE=-w
BACKUPNICI=-e
NICIPWD=secret
BACKUPPATH=/opt/novell/edir.backups
if [ -z "$1" ]; then
if [ "$1" != "-q" ]; then
echo "Running in verbose mode. Use -q for fewer messages."
VERBOSE="yes"
fi
else
VERBOSE="no"
fi
# For each configured eDirectory instance, get the instance configuration file
for i in $(cat /etc/opt/novell/eDirectory/conf/.edir/instances.0); do
if [ "$VERBOSE" == "yes" ]; then
echo "Parsing config file $i"
fi
DIBDIR=`grep "n4u.nds.dibdir" $i | cut -d '=' -f 2`
TREENAME=`grep "n4u.base.tree-name" $i | cut -d '=' -f 2`
if [ "$VERBOSE" == "yes" ]; then
echo " DIBDIR is $DIBDIR"
echo " TREENAME is $TREENAME"
fi
/etc/nds-1.conf
/etc/nds-2.conf
/etc/nds-3.conf
# eDirectory 8.8.5 version
# Check to see if the instance is currently hosted on this server
if [ -d "$DIBDIR" ]; then
echo " Tree $TREENAME is hosted on this server. Backup starting: `date`."
echo "/tmp/dsbk.config" > /etc/dsbk.conf
echo "$TODO $BACKUPTYPE $BACKUPTO $BACKUPPATH/$TREENAME.backup $BACKUPLOG $BACKUPPATH/$TREENAME-backup.log $BACKUPSTREAMS $OVERWRITE $BACKUPNICI $NICIPWD" > /tmp/dsbk.config
/opt/novell/eDirectory/bin/ndstrace --config-file $i -c "load dsbk"
# eDirectory 8.8.6 version
# Check to see if the instance is currently hosted on this server
if [ -d "$DIBDIR" ]; then
echo " Tree $TREENAME is hosted on this server. Backup starting: `date`."
/opt/novell/eDirectory/bin/ndstrace -c "load dsbk $TODO $BACKUPTYPE $BACKUPTO $BACKUPPATH/$TREENAME.backup $BACKUPLOG $BACKUPPATH/$TREENAME-backup.log $BACKUPSTREAMS $OVERWRITE $BACKUPNICI $NICIPWD --config-file $i"
# Wait for backup to complete
OSIZE=0
CSIZE=1
while [ $OSIZE -ne $CSIZE ];
do
if [ "$VERBOSE" == "yes" ]; then
echo " Waiting for backup of $TREENAME to complete."
fi
sleep 10
OSIZE=$CSIZE
CSIZE=`stat --format="%s" $BACKUPPATH/$TREENAME.backup`
done
if [ "$VERBOSE" == "yes" ]; then
echo
fi
echo " Backup of $TREENAME done: `date`."
sleep 10
if [ "$VERBOSE" == "yes" ]; then
echo " Checking status of backup."
fi
tail -1 $BACKUPPATH/$TREENAME-backup.log | grep "success" > /dev/null
if [ "$?" -ne 0 ]; then
echo " Backup failed."
cat $BACKUPPATH/$TREENAME-backup.log
exit 1
else
echo " Backup completed successfully."
fi
#!/bin/bash
# eDirectory 8.8.5 version
# Backup Options:
#
# 'backup' Perform an eDirectory backup
# -b Performs a full backup of the eDirectory database.
# -f Specifies the path and file to back up to
# -l Specifies the log file for the back up
# -t Includes the stream files when backing up the eDirectory database.
# -w Overwrites the backup file specified with the -f switch if a file of the same name already exists.
# -e <pwd> Includes the NICI encryption keys using password <pwd>
TODO=backup
BACKUPTYPE=-b
BACKUPTO=-f
BACKUPLOG=-l
BACKUPSTREAMS=-t
OVERWRITE=-w
BACKUPNICI=-e
NICIPWD=secret
BACKUPPATH=/opt/novell/edir.backups
if [ -z "$1" ]; then
if [ "$1" != "-q" ]; then
echo "Running in verbose mode. Use -q for fewer messages."
VERBOSE="yes"
fi
else
VERBOSE="no"
fi
# For each configured eDirectory instance, get the instance configuration file
for i in $(cat /etc/opt/novell/eDirectory/conf/.edir/instances.0); do
if [ "$VERBOSE" == "yes" ]; then
echo "Parsing config file $i"
fi
DIBDIR=`grep "n4u.nds.dibdir" $i | cut -d '=' -f 2`
TREENAME=`grep "n4u.base.tree-name" $i | cut -d '=' -f 2`
if [ "$VERBOSE" == "yes" ]; then
echo " DIBDIR is $DIBDIR"
echo " TREENAME is $TREENAME"
fi
# Check to see if the instance is currently hosted on this server
if [ -d "$DIBDIR" ]; then
echo " Tree $TREENAME is hosted on this server. Backup starting: `date`."
echo "/tmp/dsbk.config" > /etc/dsbk.conf
echo "$TODO $BACKUPTYPE $BACKUPTO $BACKUPPATH/$TREENAME.backup $BACKUPLOG $BACKUPPATH/$TREENAME-backup.log $BACKUPSTREAMS $OVERWRITE $BACKUPNICI $NICIPWD" > /tmp/dsbk.config
/opt/novell/eDirectory/bin/ndstrace --config-file $i -c "load dsbk"
# Wait for backup to complete
OSIZE=0
CSIZE=1
while [ $OSIZE -ne $CSIZE ];
do
if [ "$VERBOSE" == "yes" ]; then
echo " Waiting for backup of $TREENAME to complete."
fi
sleep 10
OSIZE=$CSIZE
CSIZE=`stat --format="%s" $BACKUPPATH/$TREENAME.backup`
done
if [ "$VERBOSE" == "yes" ]; then
echo
fi
echo " Backup of $TREENAME done: `date`."
sleep 10
if [ "$VERBOSE" == "yes" ]; then
echo " Checking status of backup."
fi
tail -1 $BACKUPPATH/$TREENAME-backup.log | grep "success" > /dev/null
if [ "$?" -ne 0 ]; then
echo " Backup failed."
cat $BACKUPPATH/$TREENAME-backup.log
exit 1
else
echo " Backup completed successfully."
fi
else
echo " Tree $TREENAME is not currently hosted on this server. Skipping..."
fi
echo
done
#!/bin/bash
# eDirectory 8.8.6 version
# Backup Options:
#
# 'backup' Perform an eDirectory backup
# -b Performs a full backup of the eDirectory database.
# -f Specifies the path and file to back up to
# -l Specifies the log file for the back up
# -t Includes the stream files when backing up the eDirectory database.
# -w Overwrites the backup file specified with the -f switch if a file of the same name already exists.
# -e <pwd> Includes the NICI encryption keys using password <pwd>
TODO=backup
BACKUPTYPE=-b
BACKUPTO=-f
BACKUPLOG=-l
BACKUPSTREAMS=-t
OVERWRITE=-w
BACKUPNICI=-e
NICIPWD=secret
BACKUPPATH=/opt/novell/edir.backups
if [ -z "$1" ]; then
if [ "$1" != "-q" ]; then
echo "Running in verbose mode. Use -q for fewer messages."
VERBOSE="yes"
fi
else
VERBOSE="no"
fi
# For each configured eDirectory instance, get the instance configuration file
for i in $(cat /etc/opt/novell/eDirectory/conf/.edir/instances.0); do
if [ "$VERBOSE" == "yes" ]; then
echo "Parsing config file $i"
fi
DIBDIR=`grep "n4u.nds.dibdir" $i | cut -d '=' -f 2`
TREENAME=`grep "n4u.base.tree-name" $i | cut -d '=' -f 2`
if [ "$VERBOSE" == "yes" ]; then
echo " DIBDIR is $DIBDIR"
echo " TREENAME is $TREENAME"
fi
# Check to see if the instance is currently hosted on this server
if [ -d "$DIBDIR" ]; then
echo " Tree $TREENAME is hosted on this server. Backup starting: `date`."
/opt/novell/eDirectory/bin/ndstrace -c "load dsbk $TODO $BACKUPTYPE $BACKUPTO $BACKUPPATH/$TREENAME.backup $BACKUPLOG $BACKUPPATH/$TREENAME-backup.log $BACKUPSTREAMS $OVERWRITE $BACKUPNICI $NICIPWD --config-file $i"
# Wait for backup to complete
OSIZE=0
CSIZE=1
while [ $OSIZE -ne $CSIZE ];
do
if [ "$VERBOSE" == "yes" ]; then
echo " Waiting for backup of $TREENAME to complete."
fi
sleep 10
OSIZE=$CSIZE
CSIZE=`stat --format="%s" $BACKUPPATH/$TREENAME.backup`
done
if [ "$VERBOSE" == "yes" ]; then
echo
fi
echo " Backup of $TREENAME done: `date`."
sleep 10
if [ "$VERBOSE" == "yes" ]; then
echo " Checking status of backup."
fi
tail -1 $BACKUPPATH/$TREENAME-backup.log | grep "success" > /dev/null
if [ "$?" -ne 0 ]; then
echo " Backup failed."
cat $BACKUPPATH/$TREENAME-backup.log
exit 1
else
echo " Backup completed successfully."
fi
else
echo " Tree $TREENAME is not currently hosted on this server. Skipping..."
fi
echo
done