jlewter Absent Member.
Absent Member.
1553 views

Automating DSBK in cron

I am setting up an automated job on each of my SLES11SP4 servers to backup edirectory 8.8. I have tested it several times just running the command with the options I want and it works fine. I place the job in cron though and it want run. Here is a script of what I am running:

o 2 * * 0 /opt/novell/eDirectory/bin/dsbk backup -b -e -f /var/opt......

I check the log and I get this error:

line 156: ndstrace: command not found

I have tried in the above example, plus running it with the . / in front of it and get the same error. It doesn't appear to be a path issue since I can run it manually either way and it works, just not in crontab. Any help would be appreciated.
Labels (1)
0 Likes
7 Replies
Knowledge Partner
Knowledge Partner

Re: Automating DSBK in cron

On 02/14/2016 11:36 AM, jlewter wrote:
>
> I am setting up an automated job on each of my SLES11SP4 servers to
> backup edirectory 8.8. I have tested it several times just running the
> command with the options I want and it works fine. I place the job in
> cron though and it want run. Here is a script of what I am running:
>
> o 2 * * 0 /opt/novell/eDirectory/bin/dsbk backup -b -e -f
> /var/opt......


I doubt this is the line from your conrab, as you have an o (oh) instead
of a zero (0) as your first chracter. Please copy/paste in the future,
just in case something else looks interesting.

> I check the log and I get this error:
>
> line 156: ndstrace: command not found


I'm not sure why ndstrace would be called, unless it is to load the dsbk
module, but the best way to do this is probably found in the documentation
with other commands where it mentions prepending those commands with ndspath:


/opt/novell/eDirectory/bin/ndspath /opt/novell/eDirectory/bin/dsbk ...


See if that provides what you are after, and let us know.

> I have tried in the above example, plus running it with the . / in front
> of it and get the same error. It doesn't appear to be a path issue since


The 'dot' command is to source a file (also, use the 'source" command
instead in all cases, please, as it is simpler to understand, less-likely
to be confusing or cause typos, etc.) and it is meant for ndspath, not for
other commands. Using ndspath as I mentioned above should work around
this. Alternatively, you can, in your crontab file, set PATH (and other
variables) explicitly, though in your case I'd try the ndspath command
option first.

> I can run it manually either way and it works, just not in crontab. Any
> help would be appreciated.


crontab has a pretty-well-documented feature in that it does not preserve
your user's PATH in many/most/all(?) cases, and as a result PATH problems
are very common, and this is usually a very good thing for security and
reliability, but it does mean that you need to set things up properly to
work at all. I think the example above should get you there, but if not
let us know what output you see and let's go from there.

--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...
0 Likes
jlewter Absent Member.
Absent Member.

Re: Automating DSBK in cron

Yes, that is a typo on my part. I haven't tried it putting the ndspath path in front of the actual command. That makes for a very long command or sure. I edited it and put the path statement in front of it and that worked. I manually entered all the path statements required for edirectory on the box in the /etc/profile upon installation, so cron must be pulling from a different path config that I am not aware of then. It works this way, but there has got to be a way to make it work without putting the path in front of it. Thanks for your help anyway, it got it work none the least.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Automating DSBK in cron

jlewter;2419800 wrote:
Yes, that is a typo on my part. I haven't tried it putting the ndspath path in front of the actual command. That makes for a very long command or sure. I edited it and put the path statement in front of it and that worked. I manually entered all the path statements required for edirectory on the box in the /etc/profile upon installation, so cron must be pulling from a different path config that I am not aware of then. It works this way, but there has got to be a way to make it work without putting the path in front of it. Thanks for your help anyway, it got it work none the least.


This behavior is as expected when running scripts from cron.

As you don't get a full user environment (as you do when logging in as that user) the script will not always be able to find utilities that are called.

Add the following line to your script and it should run correctly (as ndsbackup calls other binaries it needs) :

#adding search path eDir tools for cron
PATH=$PATH:/opt/novell/eDirectory/bin



As reference, this is what I've been using (quick and dirty, and a very old script I have - buy hey... it works for me):



#!/bin/bash
#
# eDirectory backup script ndsbackup and dsbk

echo "Start eDir backup script : $(date +%Y-%m-%d)" >> /backup/edirbckdone.log

#adding search path eDir tools for cron
PATH=$PATH:/opt/novell/eDirectory/bin

echo "skipping Metamig dump..."
##metamig save DATA > /backup/nss/nss-trustees-data_`date +%Y-%m-%d`
# LET OP Metamig is an optional method to backup metadata - handy if your backup solution does not support restoring metadata

echo "starting ndsbackup..."
##NDSbackup for object restores
/opt/novell/eDirectory/bin/ndsbackup cvf /backup/nds/nds_day"$(date +%d)".edir -a [adminaccount.context] -p [wachtwoord] > /dev/null
sleep 4
#tar zip file to save space
tar cfz /backup/nds/nds_day"$(date +%d)".tar.gz /backup/nds/nds_day"$(date +%d)".edir
sleep 2
#remove original untar'd dump
rm /backup/nds/nds_day"$(date +%d)".edir
echo "ndsbackup done : $(date +%Y-%m-%d)" >> /backup/edirbckdone.log

echo "starting dsbk..."
##DSbk for directory disaster recovery
/opt/novell/eDirectory/bin/dsbk backup -b -f /backup/dsbk/dsbk_$HOSTNAME.bak -l /backup/dsbk/dsbackup.log -t -w
#Wait for dump to complete
sleep 30
#Create tar zip to save space
tar cfz /backup/dsbk/dsbk_$HOSTNAME_day"$(date +%d)".tar.gz /backup/dsbk/dsbk_$HOSTNAME.bak
#remove original untar'd dump
rm /backup/dsbk/dsbk_$HOSTNAME.bak
echo "dsbk done : $(date +%Y-%m-%d)" >> /backup/edirbckdone.log



Cheers,
Willem
0 Likes
jlewter Absent Member.
Absent Member.

Re: Automating DSBK in cron

I was using a scipt, just placing the command directly in cron. I added the /opt/novell/eDirectory/bin/ndspath in front of the command and it works. I also had to add the path statement for what edirectory requires in the /etc/profile so once doing all of that it works. Just curious why you're doing ndsbackup and dsbk?
0 Likes
Knowledge Partner
Knowledge Partner

Re: Automating DSBK in cron

dsbk is useful when a server explodes and is not recoverable, or when all
servers explode and are not recoverable. It is not useful if eDirectory
is working but somebody does something silly and deletes/damages/etc. one
or more objects in the otherwise-healthy tree. ndsbackup is an
object-by-object backup, so you can restore, or at least see, objects as
they were at a point in time without restoring an entire server's DIB.

In summary, they serve different purposes. Do both from time to time for
the most flexibility in recovering from acts of God
(servers/datacenters/etc. explode) as well as acts of the fallible beings
we are (deleting/modifying/moving/etc. users in ways that are bad).


--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...
0 Likes
Knowledge Partner
Knowledge Partner

Re: Automating DSBK in cron

On Sun, 14 Feb 2016 18:36:03 +0000, jlewter wrote:

> I am setting up an automated job on each of my SLES11SP4 servers to
> backup edirectory 8.8.


I wrote this Cool Solution a while ago:

https://www.netiq.com/communities/cool-solutions/backups-multi-instance-
edirectory-linux/

You might find it helpful.


> I have tested it several times just running the
> command with the options I want and it works fine. I place the job in
> cron though and it want run. Here is a script of what I am running:
>
> o 2 * * 0 /opt/novell/eDirectory/bin/dsbk backup -b -e -f /var/opt......
>
> I check the log and I get this error:
>
> line 156: ndstrace: command not found


You need to specify full paths to things, or set the path appropriately.


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.microfocus.com

Please post questions in the forums. No support provided via email.
If you find this post helpful, please click on the star below.
0 Likes
jlewter Absent Member.
Absent Member.

Re: Automating DSBK in cron

Thanks, I will check out the cool solution article you.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.