Remote Backups and Restores Using SSH
As shown above, you can use the special filenames stdin and stdout to backup and restore a database to a separate database on the same server.However, you can also use the same tools, over an SSH connection to a remote server, and pass the backup of one database directly to a restoration of a separate one.
The first example copies a local database to a remote server where Firebird is running and the firebird user has its environment set up so that the gbak tool is on $PATH by default, on login.
|
Note
|
In each of the following examples, the |
tux> # Clone a test database to a different server, without requiring a backup file.
tux> gbak -backup employee stdout | \
ssh firebird@tuxrep "gbak {...} -r o stdin emptest"
When the above is executed, you will be prompted for a password for the remote firebird user on server tuxrep, assuming that you don’t have a proper SSH key-pair already set up and active.The command will replace the local database according to the alias name emptest, but you can, if required, supply full path names for the databases.The following shows an example of the above being executed.
tux> # Clone a test database to a different server, without requiring a backup file.
tux> gbak -backup employee stdout | \
ssh firebird@tuxrep "gbak {...} -r o stdin emptest"
firebird@tuxrep's password:
As you can see, there’s not much in the way of output, but you can connect remotely and check:
tux> isql {...} tuxrep:emptest
Database: tuxrep:emptest
SQL> show database;
Database: tuxrep:emptest
Owner: SYSDBA
PAGE_SIZE 4096
...
The next example, shows a remote database being backed up to a local one, in a similar manner.
tux> ssh firebird@tuxrep "gbak -backup {...} emptest stdout" | \
gbak -create stdin data/tuxrep_emptest.fdb
firebird@tuxrep's password:
tux> ls data
employee.fdb tuxrep_emptest.fdb
You can see that a new tuxrep_emptest.fdb database has been created.Does it work?Checking with isql shows that it does.
tux> isql data/tuxrep_emptest.fdb Database: data/tuxrep_emptest.fdb SQL> quit;
The final example shows how to backup a remote database on one server, to a remote database on another.
tux> ssh firebird@tuxrep "gbak -backup {...} emptest stdout" | \
ssh firebird@tuxqa "gbak -create {...} stdin data/tuxrep_empqa.fdb"
firebird@tuxrep's password:
firebird@tuxqa's password
tux> ssh firebird@tuxqa "ls data"
employee.fdb tuxrep_empqa.fdb