473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Backup via Cron

Hi,
we are using DB2 on Fedora

We try to backup the datbases automatically every day (night). For this
purpose, I wrote two scripts, a shell (bash) and a sql script.
The shell script set the profile and call the sql script.

******* short form
/home/db2iusr/sqllib/db2profile
/opt/IBM/db2/V8.1/bin/db2 -tvf /db2/backup/db2-backup.sql
*******

The sql script performs the backup like this:
*******
force application all;
backup database <db> user <user> using <pw> to <dir> without prompting;
quit;
*******

Problem:
--------
When we call the shell script manually using the bash, there is no
problem. But, if we use the unix cron to backup the databases daily and
automatically we receive every time the following error

SQL10007N Message "-1390" could not be retrieved. Reason code: "1".

If we paste all rows from the db2profile to shell script we receive the
same error message with reason code 2.

Any suggestions would be helpful.
Toralf
Nov 12 '05 #1
7 8010
Toralf,

on AIX I have to put the whole PATH in the .ksh-Script

PATH=...
export PATH

But, also you can use the DB2 Scheduler with CC, it works very well.

regards,
Joachim Müller

"Toralf Kirsten" <tk******@izbi.uni-leipzig.de> schrieb im Newsbeitrag
news:ca**********@news.uni-leipzig.de...
Hi,
we are using DB2 on Fedora

We try to backup the datbases automatically every day (night). For this
purpose, I wrote two scripts, a shell (bash) and a sql script.
The shell script set the profile and call the sql script.

******* short form
/home/db2iusr/sqllib/db2profile
/opt/IBM/db2/V8.1/bin/db2 -tvf /db2/backup/db2-backup.sql
*******

The sql script performs the backup like this:
*******
force application all;
backup database <db> user <user> using <pw> to <dir> without prompting;
quit;
*******

Problem:
--------
When we call the shell script manually using the bash, there is no
problem. But, if we use the unix cron to backup the databases daily and
automatically we receive every time the following error

SQL10007N Message "-1390" could not be retrieved. Reason code: "1".

If we paste all rows from the db2profile to shell script we receive the
same error message with reason code 2.

Any suggestions would be helpful.
Toralf

Nov 12 '05 #2
Ian
Toralf Kirsten wrote:
Hi,
we are using DB2 on Fedora

We try to backup the datbases automatically every day (night). For this
purpose, I wrote two scripts, a shell (bash) and a sql script.
The shell script set the profile and call the sql script.

******* short form
/home/db2iusr/sqllib/db2profile


This should read:

. /home/db2iusr/sqllib/db2profile

The '.' executes the db2profile in the current shell (i.e. all environment
variables are exported in the _current_ shell).

As you've written it, you are executing the db2profile in a sub shell.
The variables get set in the sub-shell, and then the sub-shell exits.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #3
Toralf Kirsten <tk******@izbi.uni-leipzig.de> wrote in message news:<ca**********@news.uni-leipzig.de>...

Are you really reading the db2profile? On aix you would need to 'dot'
it rather than run it - since it doesn't have a #! at the top.

So, instead of this:
******* short form
/home/db2iusr/sqllib/db2profile
/opt/IBM/db2/V8.1/bin/db2 -tvf /db2/backup/db2-backup.sql
*******
I'd have this:
******* short form
. /home/db2iusr/sqllib/db2profile
db2 -tvf /db2/backup/db2-backup.sql
*******


The fact that you could run it manually could easily be masked by your
own user profile, unless you explicitely isabled it.

buck
Nov 12 '05 #4
Ian,
many thanks for your reply.
You are right. It's a mistake and I corrected the script.
The shell script is now like this:
*******
.. /home/db2iusr/sqllib/db2profile
/opt/IBM/db2/V8.1/bin/db2 -tvf /db2/backup/db2-backup.sql
*******

The sql script is like this:
*******
force application all;
backup database <db> user <user> using <pw> to <dir> without prompting;
quit;
*******

Now I get the same error with reason code 2.
SQL10007N Message "-1390" could not be retrieved. Reason code: "2".
I think it is a simple error, but I don't know what's wrong.

Thanks, Toralf
Ian wrote:
Toralf Kirsten wrote:
Hi,
we are using DB2 on Fedora

We try to backup the datbases automatically every day (night). For
this purpose, I wrote two scripts, a shell (bash) and a sql script.
The shell script set the profile and call the sql script.

******* short form
/home/db2iusr/sqllib/db2profile

This should read:

. /home/db2iusr/sqllib/db2profile

The '.' executes the db2profile in the current shell (i.e. all environment
variables are exported in the _current_ shell).

As you've written it, you are executing the db2profile in a sub shell.
The variables get set in the sub-shell, and then the sub-shell exits.

Nov 12 '05 #5
> When we call the shell script manually using the bash, there is no
problem. But, if we use the unix cron to backup the databases daily and
automatically we receive every time the following error

SQL10007N Message "-1390" could not be retrieved. Reason code: "1".


This often means that DB2INSTANCE is not set.

dave
Nov 12 '05 #6
Joachim,
thanks for your reply.
After modifying the script by using the dot in front of calling the
db2profile script, I print out two variables within my script which are
set in db2profile script.

The result is:
backup uses the DB2INSTANCE: db2iusr
use the paths:
/sbin:/bin:/usr/sbin:/usr/bin:/home/db2iusr/sqllib/bin:/home/db2iu
sr/sqllib/adm:/home/db2iusr/sqllib/misc

The db2 instance is set correctly. But, I'm not really sure which
additional path I have to set.

Now, I get the error
SQL10007N Message "-1390" could not be retrieved. Reason code: "2".

Toralf

Joachim Mueller wrote:
Toralf,

on AIX I have to put the whole PATH in the .ksh-Script

PATH=...
export PATH

But, also you can use the DB2 Scheduler with CC, it works very well.

regards,
Joachim Müller


Nov 12 '05 #7
Hi,
just to give the solution of the problem.
There were two errors.

First, as proposed by other guys, the dot in front of the command
loading the db2 environment was missed. The right string is as follows
.. /home/db2iusr/sqllib/db2profile or alternatively
source /home/db2iusr/sqllib/db2profile

Second, we set the lang variables $LANG to en_US.UTF-8 which was set in
the normal user environment but not in the CRON environment.

Hope it helps you in similar cases.
Cheers, Toralf
Toralf Kirsten wrote:
Hi,
we are using DB2 on Fedora

We try to backup the datbases automatically every day (night). For this
purpose, I wrote two scripts, a shell (bash) and a sql script.
The shell script set the profile and call the sql script.

******* short form
/home/db2iusr/sqllib/db2profile
/opt/IBM/db2/V8.1/bin/db2 -tvf /db2/backup/db2-backup.sql
*******

The sql script performs the backup like this:
*******
force application all;
backup database <db> user <user> using <pw> to <dir> without prompting;
quit;
*******

Problem:
--------
When we call the shell script manually using the bash, there is no
problem. But, if we use the unix cron to backup the databases daily and
automatically we receive every time the following error

SQL10007N Message "-1390" could not be retrieved. Reason code: "1".

If we paste all rows from the db2profile to shell script we receive the
same error message with reason code 2.

Any suggestions would be helpful.
Toralf

Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Neil | last post by:
Hi, I hope this question isn't too far off topic....I'm almost at my wits end trying to figure this out. I have a Mysql database and I wish to automate the backup of the database because I...
1
by: Konrad | last post by:
I have an internet portal based on MySql database and what I need is to make a database backup , after each actualization of data. I know how should PHP code look like but I have no idea how to...
2
by: Robert Fitzpatrick | last post by:
I'm sure this has been discussed many times. I can find references to the problem in the archives, but decided to query the list here instead of sifting through archives all day. Is there a way...
3
by: mrwheel | last post by:
Hello I am seeking after a backup script, to take backup of my webspace on my server, my server is www.servage.net i need to take backup 2 times per day. Via cronjob on www.cronjob.de but i have...
7
by: damezumari | last post by:
I use Windows XP and Apache. I am trying to backup a database on my local computer with the following php code: $dbname = 'ol'; $dbhost = 'localhost'; $dbuser = 'root'; $dbpass =...
5
by: overcomersonline | last post by:
We have a Perl script that is supposed to back up all our files, folders and databases on our server however its sending an error via email. This is the error Unrecognized character \xA6 at...
4
by: Aidan | last post by:
Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying...
2
zorgi
by: zorgi | last post by:
Hi Basically I have table TABLE_1 with number of fields being updated all the time. Once a month I run cron job and all the records in TABLE_1 become not needed for my next cron job. Now I need to...
4
by: bsamer | last post by:
Well very simply i have a script when i run it manualy from the root it will work but from the crontab. I get an error The problem is from root i run the script which will define all the env. var....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.