Board index » delphi » GBAK fails when scheduled in NT task scheduler

GBAK fails when scheduled in NT task scheduler

I have the following batch file

d:
cd "\Program Files\Borland\InterBase\bin\"
net stop InterBaseGuardian >> d:\risk\ed.txt
net stop InterBaseServer >> d:\risk\ed.txt
net start InterBaseGuardian >> d:\risk\ed.txt
d:\risk\gfix -sh -force 0 d:\risk\Risks.gdb -user "sysdba" -pass
"somepassword"
copy d:\risk\Risks.gdb d:\risk\Risks.sav
d:\risk\gbak -B -b -v d:\risk\Risks.gdb d:\risk\Risks.gbk -user
"sysdba" -pass "somepassword"
d:\risk\gbak -R -r -p 8192 -v d:\risk\Risks.gbk d:\risk\Risks.gdb  -user
"sysdba" -password "somepassword"
d:\risk\gfix -o d:\risk\Risks.gdb -user "sysdba" -password "somepassword"

When I run this by double clicking it, it works just fine.
However when I schedule it to run (as administrator) it
fails.  The following shows up in the -y logfile.

gbak: ERROR: unavailable database
gbak: Exiting before completion due to errors

Any ideas why this would work when double clicked and signed on
as administrator, but now from the task scheduler?

 

Re:GBAK fails when scheduled in NT task scheduler


Try to use remote connections, even for a local connection by
using "localhost:d:\risk\Risks.gdb"

HTH,
Thomas Steinmaurer
IB LogManager 2.0 - The Logging Tool for Interbase/Firebird
http://www.iblogmanager.com

"Edwin" <Edavid3...@primeinc.com> schrieb im Newsbeitrag
news:3cea9b15$1_2@dnews...

Quote
> I have the following batch file

> d:
> cd "\Program Files\Borland\InterBase\bin\"
> net stop InterBaseGuardian >> d:\risk\ed.txt
> net stop InterBaseServer >> d:\risk\ed.txt
> net start InterBaseGuardian >> d:\risk\ed.txt
> d:\risk\gfix -sh -force 0 d:\risk\Risks.gdb -user "sysdba" -pass
> "somepassword"
> copy d:\risk\Risks.gdb d:\risk\Risks.sav
> d:\risk\gbak -B -b -v d:\risk\Risks.gdb d:\risk\Risks.gbk -user
> "sysdba" -pass "somepassword"
> d:\risk\gbak -R -r -p 8192 -v d:\risk\Risks.gbk d:\risk\Risks.gdb  -user
> "sysdba" -password "somepassword"
> d:\risk\gfix -o d:\risk\Risks.gdb -user "sysdba" -password "somepassword"

> When I run this by double clicking it, it works just fine.
> However when I schedule it to run (as administrator) it
> fails.  The following shows up in the -y logfile.

> gbak: ERROR: unavailable database
> gbak: Exiting before completion due to errors

> Any ideas why this would work when double clicked and signed on
> as administrator, but now from the task scheduler?

Re:GBAK fails when scheduled in NT task scheduler


Quote
Edwin wrote:
> ...
> When I run this by double clicking it, it works just fine.
> However when I schedule it to run (as administrator) it
> fails.  The following shows up in the -y logfile.
> gbak: ERROR: unavailable database
> gbak: Exiting before completion due to errors
> Any ideas why this would work when double clicked and signed on
> as administrator, but now from the task scheduler?

Does it change anything if you include the /interactive switch when you
give the AT command?

Regards,
Aage J.

Re:GBAK fails when scheduled in NT task scheduler


You might also want to change the path from  "\Program
Files\Borland\InterBase\bin\" to "\Progra~1\Borland\InterBase\bin\".  I've
had similar problems like this and had to use the actual DOS read path (even
though it is a console and not really DOS) rather than the long filename
path.

Erik

Quote
"Edwin" <Edavid3...@primeinc.com> wrote in message

news:3cea9b15$1_2@dnews...
Quote
> I have the following batch file

> d:
> cd "\Program Files\Borland\InterBase\bin\"
> net stop InterBaseGuardian >> d:\risk\ed.txt
> net stop InterBaseServer >> d:\risk\ed.txt
> net start InterBaseGuardian >> d:\risk\ed.txt
> d:\risk\gfix -sh -force 0 d:\risk\Risks.gdb -user "sysdba" -pass
> "somepassword"
> copy d:\risk\Risks.gdb d:\risk\Risks.sav
> d:\risk\gbak -B -b -v d:\risk\Risks.gdb d:\risk\Risks.gbk -user
> "sysdba" -pass "somepassword"
> d:\risk\gbak -R -r -p 8192 -v d:\risk\Risks.gbk d:\risk\Risks.gdb  -user
> "sysdba" -password "somepassword"
> d:\risk\gfix -o d:\risk\Risks.gdb -user "sysdba" -password "somepassword"

> When I run this by double clicking it, it works just fine.
> However when I schedule it to run (as administrator) it
> fails.  The following shows up in the -y logfile.

> gbak: ERROR: unavailable database
> gbak: Exiting before completion due to errors

> Any ideas why this would work when double clicked and signed on
> as administrator, but now from the task scheduler?

Re:GBAK fails when scheduled in NT task scheduler


If I run it with at using the /interactive switch I get:

gbak: ERROR: operating system directive CreateFile failed
gbak: ERROR:     The requested operation cannot be performed on a file with
a user-mapped section open.
gbak: Exiting before completion due to errors

This program runs correctly when double clicked upon.

If I put in LOCALHOST: or servername: before the filename
(localhost:d:\risk\risks.gdb)
then I get the error that the database cannot be located.  Regardless of if
it is scheduled
or if it is double clicked upon.

The original error was

gbak: ERROR: unavailable database
gbak: Exiting before completion due to errors

Changing the path to
cd "\Progra~1\Borland\InterBase\bin\"
did not help either.

Any other ideas?  I am all ears.

Re:GBAK fails when scheduled in NT task scheduler


This is what I've used in the past:  Note that your install path is most
likely different.

d:\intrbase\bin\gbak -b -t servername:d:\intrbase\data\database.gdb
d:\intrbase\data\database.gbk 2> d:\intrbase\data\log.txt -user
"SYSDBA" -password "masterkey"

The >2 d:\intrbase\data\log.txt is optional. I did this so if there were any
errors, I would see them in the morning.  This was scheduled to run in the
middle of the night.

Try this with yours.  Here's what the backup command should look like.

c:\Progra~1\Borland\InterBase\bin\gbak -b -v servername:d:\risk\risk.gdb
d:\risk\risk.gbk -user "SYSDBA" -password "masterkey"

Replace servername with the machine name as seen by a client.

Erik

Quote
"Edwin" <Edavid3...@primeinc.com> wrote in message

news:3cea9b15$1_2@dnews...
Quote
> I have the following batch file

> d:
> cd "\Program Files\Borland\InterBase\bin\"
> net stop InterBaseGuardian >> d:\risk\ed.txt
> net stop InterBaseServer >> d:\risk\ed.txt
> net start InterBaseGuardian >> d:\risk\ed.txt
> d:\risk\gfix -sh -force 0 d:\risk\Risks.gdb -user "sysdba" -pass
> "somepassword"
> copy d:\risk\Risks.gdb d:\risk\Risks.sav
> d:\risk\gbak -B -b -v d:\risk\Risks.gdb d:\risk\Risks.gbk -user
> "sysdba" -pass "somepassword"
> d:\risk\gbak -R -r -p 8192 -v d:\risk\Risks.gbk d:\risk\Risks.gdb  -user
> "sysdba" -password "somepassword"
> d:\risk\gfix -o d:\risk\Risks.gdb -user "sysdba" -password "somepassword"

> When I run this by double clicking it, it works just fine.
> However when I schedule it to run (as administrator) it
> fails.  The following shows up in the -y logfile.

> gbak: ERROR: unavailable database
> gbak: Exiting before completion due to errors

> Any ideas why this would work when double clicked and signed on
> as administrator, but now from the task scheduler?

Re:GBAK fails when scheduled in NT task scheduler


Quote
Edwin wrote:
> If I run it with at using the /interactive switch I get:
> gbak: ERROR: operating system directive CreateFile failed
> gbak: ERROR:     The requested operation cannot be performed on a file with
> a user-mapped section open.
> gbak: Exiting before completion due to errors
> ...

You used the /interactive switch on the AT command, didn't you?  Like:
at 18:00 /interactive /every:M,T,W,Th,F,S,Su C:\XXX\YYY-backup.cmd

The C:\XXX\YYY-backup.cmd contains:
"C:\Program Files\Firebird\bin\gbak" -b -v -user SYSDBA -passw
masterkey  D:\ZZZ\DB\YYY.gdb C:\ZZZ\BCKP\YYY.gbk
(on one lime!)

Regards,
Aage J.

Re:GBAK fails when scheduled in NT task scheduler


Yes I used the /interactive switch - didn't make a difference.  I use AT
everyday to push patches and software installs..  Didn't help in this
instance.  I ended up using the C:\WINNT\TASKS scheduler vs. AT and got it
working -- see other reply in this post.

Re:GBAK fails when scheduled in NT task scheduler


Okay -- I think I got it working.  Thanks for everyones help.  Here is what
I ended up with:

Of course the > on the GFIX lines don't result in output, and there is no -y
command so I
am hopefull the gfix is working..  This will run around midnight to do
database backups
and maintenance.  This was requested by my product vendor, who hasn't used
version
6.5 yet - so I question if this needs done.  I have OFA from Veritas and I
have read
that the 6.5 version has resolved the issues where prior versions required
this once
in a while.

------------------------------------------------------
d:
cd "\Progra~1\Borland\InterBase\bin\"
net stop InterBaseGuardian >> d:\risk\ed.txt
net stop InterBaseServer >> d:\risk\ed.txt
net start InterBaseGuardian >> d:\risk\ed.txt
del D:\risk\risklog1.txt
del D:\risk\risklog2.txt
del D:\risk\servicelog1.txt
del D:\risk\servicelog2.txt
del d:\risk\*.gbk

d:\Progra~1\Borland\InterBase\bin\gfix -sh -force 0
ntfs4:d:\risk\risks.gdb -user "sysdba" -pass "mypassword" >
d:\risk\risklog0.txt

copy d:\risk\Risks.gdb d:\risk\Risks.sav > d:\risk\riskscopy.log

d:\Progra~1\Borland\InterBase\bin\gbak -B -b -v ntfs4:d:\risk\risks.gdb
d:\risk\risks.gbk -user "sysdba" -pass "mypassword" -y D:\risk\risklog1.txt

d:\Progra~1\Borland\InterBase\bin\gbak -R -r -p 8192 -v d:\risk\Risks.gbk
ntfs4:d:\risk\Risks.gdb  -user "sysdba" -pass "mypassword" -y
D:\risk\risklog2.txt

d:\Progra~1\Borland\InterBase\bin\gfix -o ntfs4:d:\risk\Risks.gdb -user
"sysdba" -password "mypassword" > d:\risk\risklog3.txt

d:\Progra~1\Borland\InterBase\bin\gfix -sh -force 0
ntfs4:d:\risk\service.gdb -user "sysdba" -pass "mypassword" >
d:\risk\servicelog0.txt

copy d:\risk\service.gdb d:\risk\service.sav > d:\risk\servicecopy.log

d:\Progra~1\Borland\InterBase\bin\gbak -B -b -v ntfs4:d:\risk\service.gdb
d:\risk\service.gbk -user "sysdba" -pass "mypassword" -y
D:\risk\servicelog1.txt

d:\Progra~1\Borland\InterBase\bin\gbak -R -r -p 8192 -v d:\risk\service.gbk
ntfs4:d:\risk\service.gdb  -user "sysdba" -pass "mypassword" -y
D:\risk\servicelog2.txt

d:\Progra~1\Borland\InterBase\bin\gfix -o ntfs4:d:\risk\service.gdb -user
"sysdba" -password "mypassword" > d:\risk\servicelog3.txt

exit

Re:GBAK fails when scheduled in NT task scheduler


Just FYI....the Task Scheduler (or Sheduled Tasks) that you see in My
Computer is just a Windows GUI to the AT Scheduler.

Erik

Quote
"Edwin" <Edavid3...@primeinc.com> wrote in message

news:3ced69ea$1_1@dnews...
Quote
> Yes I used the /interactive switch - didn't make a difference.  I use AT
> everyday to push patches and software installs..  Didn't help in this
> instance.  I ended up using the C:\WINNT\TASKS scheduler vs. AT and got it
> working -- see other reply in this post.

Other Threads