Subject Re: Restoring backup database ( gbak -r some.fbk live.fb ) gives validation error for certain coloum
Author robert_p_levy
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
> NEVER USE GBAK WITH THE -r SWITCH !!! That's the first thing to
tattoo on
> your forehead.
...
> replace_database, not for "restore". If you actually backed up bad
data
> (as you did here) then gbak -r means "gbak -[dest]r[oy_database].

Helen,

Hi. I read that advice in The Firebird Book as well, but figured I
was exempt because of the way in which I used it. Now I am curious
as to whether I am wrong about that considering how strongly it is
advised against.

I run abatch file every other day on databases which are large and
frequently updated, to reduce the file size. The parameters are %
1=path of Fbird bin directory and %2=path of database.
It stops the server, makes a diskcopy (and appends the day of the
week to the file), starts the server and then runs gbak -r. This
seems safe to me because we have a few backup copies in case
something went wrong due to gbak -r. (somewhat off topic note: Of
course this ends up using more diskspace in theshort term, but in the
long run I think it keeps the size smaller than it otherwise would
increase to.)

@echo off
NET STOP FirebirdServerDefaultInstance
date /t | find "Mon"
if not errorlevel 1 goto MONDAY
date /t | find "Tue"
if not errorlevel 1 goto TUESDAY
date /t | find "Wed"
if not errorlevel 1 goto WEDNESDAY
date /t | find "Thu"
if not errorlevel 1 goto THURSDAY
date /t | find "Fri"
if not errorlevel 1 goto FRIDAY
date /t | find "Sat"
if not errorlevel 1 goto SATURDAY
date /t | find "Sun"
if not errorlevel 1 goto SUNDAY
:MONDAY
copy %2 %2~MON
goto :NEXTPART
:TUESDAY
copy %2 %2~TUE
goto :NEXTPART
:WEDNESDAY
copy %2 %2~WED
goto :NEXTPART
:THURSDAY
copy %2 %2~THU
goto :NEXTPART
:FRIDAY
copy %2 %2~FRI
goto :NEXTPART
:SATURDAY
copy %2 %2~SAT
goto :NEXTPART
:SUNDAY
copy %2 %2~SUN
:NEXTPART
NET START FirebirdServerDefaultInstance
cd %1
gbak -backup localhost:%2 %2.fb1 -user SYSDBA -password masterkey
gbak -create -r %2.fb1 %2 -user SYSDBA -password masterkey
del %2.fb1
dir %2*