How to backup a remote Firebird SQL database using GBAK

The following BAT file may be of interest if your local machine is not too far away from the database server.  It shows how to use the free GBAK utility to backup a remote Firebird SQL database, with the destination file landing locally.  

This BAT syntax is for use on Windows. 

:: backup-sample.bat

setlocal

set project=sample
set yyyymmdd=20191020

set fbroot=d:\Apps\FirebirdSQL\2.5\bin\

if NOT exist %fbroot%bin\gbak.exe ECHO "cannot find %fbroot%bin\gbak.exe"
if NOT exist %fbroot%bin\gbak.exe pause

:: define target folder 
set bakdir=c:\fbtemp\
mkdir %bakdir%

cls

:: FYI syntax for the source when db is local
set DBName=c:\santral\data\santral.fdb

:: syntax for remote db using alias, server:alias
set DBName=sql332.href.com:sample01

set u=SYSDBA
set p=masterkey

REM gbak  -user  -password   
REM -t transportable format

"%fbroot%bin\gbak.exe" -t -z -user %u% -password %p% %DBName% %bakdir%%project%_bak_%yyyymmdd%.fbk 
if errorlevel 1 pause


dir %bakdir%
pause

endlocal


Comments

Popular Posts