Vous êtes sur la page 1sur 4

GBAKFirebirdBackupandRestore

GBAKisFirebird'scommandlinetoolforonlinebackupandrestoreofacompletedatabase.

General Syntax
gbak <options> -user <username> -password <password> <source> <destination>

Backup Forbackups,<source>isthedatabaseyouwanttobackup,<destination>isthefilenameofthe backupfile.Theusualextensionis.fbkforFirebirdand.gbkforInterBase. OnlySYSDBAorthedatabaseownercanperformabackup.Formultifiledatabases,specifyonly thenameofthefirstfileasthedatabasename. Restore Forrestores,<source>isthebackupfileand<destination>isthenameofthedatabasethatistobe builtupfromthebackupfile.YouwillhavetospecifytheCoptionforrestore.

General Options
-pa[ssword] <password> -role <role>

Databasepassword Connectasrole Backup:Createsthebackupfileonthedatabaseserver,usingthe ServiceManager. Restore:Createsthedatabasefromabackupfileontheserver,using theServiceManager. Databaseusername VerboseoutputofwhatGBAKisdoing Redirectalloutputmessagesto<filename> ThefilemustnotexistbeforerunningGBAK! Quietmode ShowGBAKversionandserverversion

-se[rvice] <hostname>:service_mgr

-u[ser] <username> -v[erbose]

-y <filename>

-y suppress_output -z

Backup Options
-b[ackup_database] -co[nvert] -e[xpand] -fa[ctor] n -g[arbage collect] -ig[nore] -l[imbo] -m[etadata]

Backup.Thisswitchisoptional. Convertsexternaltablestointernaltables Createsanuncompressedbackup Blockingfactorfortapedevice Doesnotperformgarbagecollection(sweeping)duringbackup Ignoreschecksumerrorswhilebackingup Ignoreslimbotransactionswhilebackingup Onlybacksupmetadata(schema).Notabledatawillbestored. Nontransportableformat(useonlywhenyouknowyouwillrestoreon sameplatformanddatabaseversion) Createsatransportablebackup(transportablebetweenplatformsand serverversions)

-nt

-t[ransportable]

Restore Options
-bu[ffers] -c[reate_database] -i[nactive] -k[ill] -mo[de] read_write -mo[de] read_only

Setcachesizeforrestoreddatabase Restore(mandatory) AllindexeswillberestoredasINACTIVE Doesnotcreateshadowsthataredefinedinthebackup Restorestoaread/writedatabase(Thisisthedefault) Restorestoareadonlydatabase Doesnotrestorevalidityconstraints.Soyoucanrestoredatathatdoesnot meettheseconstraintsandcouldnotberestoredotherwise. Restoresonetableatatime.Youcanusethistopartiallyrestoredatabases withcorrupttabledata Setspagesizeofnewdatabase.<size>canbeoneof1024,2048,4096, 8192.Defaultis1024. Restoresoveranexistingdatabase.ThiscanonlybeperformedbySYSDBA

-n[o_validity]

-o[ne_at_a_time]

-p[age_size] <size>

-r[eplace_database]

ortheownerofthedatabasethatisoverwritten.DoNOTrestoreovera databasethatisinuse! Normally,onrestore,databasepageswillbefilledtoabout80%.Withthe use_all_spaceoption,databasepageswillbefilledto100%.(Usefulfor readonlydatabaseswhichwillseenomoremodifications)

-use_[all_space]

Examples
A "normal" Backup gbak -v -t -user SYSDBA -password "masterkey" dbserver:/db/warehouse.fdb c:\backups\warehouse.fbk Backup with output to a logfile gbak -v -t -user SYSDBA -password masterkey -y c:\backups\warehouse.log dbserver:/db/warehouse.fdb c:\backups\warehouse.fbk A "normal" Restore gbak -c -v -user SYSDBA -password masterkey c:\backups\warehouse.fbk dbserver:/db/warehouse2.fdb Restore to an already existing database gbak -c -r -v -user SYSDBA -password masterkey c:\backups\warehouse.fbk dbserver:/db/warehouse.fdb Create a read-only database gbak -c -v -mode read_only -use_all_space -user SYSDBA -password masterkey c:\backups\warehouse.fbk c:\files\warehousedb.fdb

Multi-file backups
Syntax for backup gbak [options] <database> <target file 1> <size 1> <target file 2> <size 2> ... <target file n> NOTE:Donotspecifyasizeforthelastfile.Itwillalwaysbefilledtotakeupwhatisleftover,no matterhowlarge. Sizecanbegiveninbytes(8192),kilobytes(1024k),megabytes(5m),orgigabytes(2g)

Syntax for restore gbak -c [options] <source file 1> <source file 2> ... <source file n> <database>

Restoring to a multi-file database


gbak -c [options] <source file> <db file 1> <size 1> <db file 2> <size 2> ... <db file n> NOTE:Donotspecifyasizeforthelastdatabasefile.Itcanalwaysgrowunlimitedtotakeupthe rest. Sizecanbegiveninbytes(8192),kilobytes(1024k),megabytes(5m),orgigabytes(2g) Restoring from a multi-file backup to a multi-file database gbak -c [options] <source file 1> <source file 2> ... <source file n> <db file 1> <size 1> <db file 2> <size 2> ... <db file n>

StefanHeymann,20040412 Thisdocumentationislicensedunder(chooseyourfavorite):GPL,LGPL,CC,IDPL,GFDL,BSD, (didIforgetone?)

Vous aimerez peut-être aussi