Subject Re: script to recreate database
Author Adam
--- In firebird-support@yahoogroups.com, "Puigsegur, Jordi"
<jordi.puigsegur@...> wrote:
>
> Yes, we know and use NBACKUP for backups, it is as you say, very fast.
> However in this case we are not looking for a backup tool, but an
> export/import tool to be able to recreate the database freeing the
> unused space.

NBACKUP wont help you here. It works at the file system level, meaning
the resulting file will contain the same unused space.

>
> 1) gbak -b -v -user SYSDBA -pas masterkey fdb.FDB fdb.bkp -y fdb.log

Use the -g switch above. If you are presumably going to do step 4
below, there is no point performing garbage collection. That will
speed it up quite a lot.



> if ERRORLEVEL 1 goto error
> 2) gbak -r -v -user SYSDBA -pas masterkey fdb.bkp fdb.new -y Log.log
>
> if ERRORLEVEL 1 goto error
> 3) No idea
> 4) del fdb.FDB
> 5) ren fdb.new fdb.fdb
> 6)No idea
>
>
>
> Any idea on how to shutdown the database before deleting it (if we don't
> do it the file is in use and we cannot delete it...)?

Most people don't have the luxury of losing data between the start of
the backup and the end of the restore (downtime is the only option, so
the connected users need to be taken care of first). The simplest way
we have found to ensure exclusive access is to rename the database file.

Another option would be to use a datapump tool. In either case, the
usual rules apply. Don't put the backup file and database on the same
physical disk to avoid thrashing. Perhaps even some sort of RAM disk
would be more useful.

Adam