Subject Re: [firebird-support] Restoring backup database ( gbak -r some.fbk live.fb ) gives validation error for certain coloum
Author Helen Borrie
At 08:41 AM 5/04/2005 +0800, you wrote:

>Dear all,
>
>Does anybody ever encounter below errors when you do "gbak -r
>some-backup.fbk the-real.fb" ? I don't have any clue what causes
>this. This is new to me.
>
>gbak: restoring data for table T_FIN_ITEM_CATEGORY_INVENTORY
> gbak: 7 records restored
> gbak: restoring index PK_T_FIN_ITEM_CATE_SVC_SALE
> gbak: restoring data for table T_FIN_ITEM_CATE_SVC_SALES
> gbak: ERROR: validation error for column TRANSTYPEID, value "*** null ***"
> gbak: ERROR: warning -- record could not be restored
> gbak: Exiting before completion due to errors
> [root@iedb april04]#

NEVER USE GBAK WITH THE -r SWITCH !!! That's the first thing to tattoo on
your forehead.

Read Alexandre's answer and teach yourself to
1) backup databases before doing stuff like adding constraints and
validation checks that will affect existing data
2) follow up metadata changes with the necessary data changes to ensure
that existing data will be valid, *before* you attempt to make another
backup. For example, in this case, you seem to have added a CHECK
(NEW.TRANSTYPEID IS NOT NULL) to this table but failed to go in and update
nulls in existing records.
and 3) an extra annoying NAG - from now until the end of your life, pretend
the -r switch on gbak does not exist. The "r" is an abbreviation for
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].

Always restore databases with the -c switch and *test* the restored
database before zapping the original.

./hb