Skip to content

Commit adf76fd

Browse files
committed
Adds guidance on backup and restore operations.
1 parent b53a23e commit adf76fd

File tree

2 files changed

+126
-5
lines changed

2 files changed

+126
-5
lines changed

README.md

+63-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ To use this image with [Firebird Events](https://firebirdsql.org/file/documentat
198198
- [Publish](https://docs.docker.com/get-started/docker-concepts/running-containers/publishing-ports/) this port to the host.
199199

200200
More information:
201-
202201
- [This answer](https://stackoverflow.com/a/49918178/33244) from Mark Rotteveel at Stack Overflow.
203202
- [The Power of Firebird Events](https://www.firebirdsql.org/file/documentation/papers_presentations/Power_Firebird_events.pdf) from Milan Babuškov.
204203

@@ -210,7 +209,7 @@ When creating a new database with `FIREBIRD_DATABASE` environment variable you c
210209

211210
Any file with extensions `.sh`, `.sql`, `.sql.gz`, `.sql.xz` and `.sql.zst` found in `/docker-entrypoint-initdb.d/` will be executed in _alphabetical_ order. `.sh` files without file execute permission (`+x`) will be _sourced_ rather than executed.
212211

213-
**IMPORTANT:** Scripts will only run if you start the container with a data directory that is empty. Any pre-existing database will be left untouched on container startup.
212+
> **IMPORTANT:** Scripts will only run if you start the container with a data directory that is empty. Any pre-existing database will be left untouched on container startup.
214213

215214

216215

@@ -231,6 +230,68 @@ Alternatively, you can use the same time zone as your host system by mapping the
231230
- /etc/timezone:/etc/timezone:ro
232231
```
233232

233+
234+
235+
## Backup and Restore
236+
237+
### For online databases
238+
239+
If the database is in use, call `gbak` inside the running container using Firebird Service Manager (`-se` switch) for best performance.
240+
241+
The following commands will backup and restore a database **in the data directory** (`/var/lib/firebird/data`) of the running container.
242+
243+
```bash
244+
# Online backup
245+
FIREBIRD_CONTAINER=MY_CONTAINER_NAME_OR_ID
246+
DATABASE_FILE=MY_DATABASE.fdb
247+
BACKUP_FILE=MY_DATABASE.fbk
248+
249+
docker exec $FIREBIRD_CONTAINER bash -c "gbak -b -user SYSDBA -pas \$FIREBIRD_ROOT_PASSWORD -se localhost:service_mgr \$FIREBIRD_DATA/$DATABASE_FILE \$FIREBIRD_DATA/$BACKUP_FILE"
250+
```
251+
252+
```bash
253+
# Online restore
254+
FIREBIRD_CONTAINER=MY_CONTAINER_NAME_OR_ID
255+
BACKUP_FILE=MY_DATABASE.fbk
256+
DATABASE_FILE=MY_DATABASE.fdb
257+
258+
docker exec $FIREBIRD_CONTAINER bash -c "gbak -c -user SYSDBA -pas \$FIREBIRD_ROOT_PASSWORD -se localhost:service_mgr \$FIREBIRD_DATA/$BACKUP_FILE \$FIREBIRD_DATA/$DATABASE_FILE"
259+
```
260+
261+
262+
263+
### For offline databases
264+
265+
> **IMPORTANT:** > Never use this with online (running) database files.
266+
267+
If you don't have a running server, create an ephemeral container to run `gbak` directly over the database files.
268+
269+
The following commands will backup and restore a database **in the current directory** (`$PWD`).
270+
271+
```bash
272+
# Offline backup
273+
FIREBIRD_IMAGE=firebirdsql/firebird
274+
DATABASE_FILE=MY_DATABASE.fdb
275+
BACKUP_FILE=MY_DATABASE.fbk
276+
277+
docker run --rm -v .:/pwd $FIREBIRD_IMAGE gbak -b /pwd/$DATABASE_FILE /pwd/$BACKUP_FILE
278+
```
279+
280+
```bash
281+
# Offline restore
282+
FIREBIRD_IMAGE=firebirdsql/firebird
283+
BACKUP_FILE=MY_DATABASE.fbk
284+
DATABASE_FILE=MY_DATABASE.fdb
285+
286+
docker run --rm -v .:/pwd $FIREBIRD_IMAGE gbak -c /pwd/$BACKUP_FILE /pwd/$DATABASE_FILE
287+
```
288+
289+
More information:
290+
- [Firebird’s gbak Backup and Restore Utility](https://firebirdsql.org/file/documentation/html/en/firebirddocs/gbak/firebird-gbak.html) from Norman Dunbar and Mark Rotteveel.
291+
- [Quick Guide for Gbak Backup-Restore](https://ib-aid.com/articles/firebird-gbak-backup-tips-and-tricks) from IBSurgeon.
292+
293+
294+
234295
# Development notes
235296

236297
## Prerequisites
@@ -264,4 +325,3 @@ To run the test suite for each image, use:
264325
```bash
265326
Invoke-Build Test
266327
```
267-

src/README.md.template

+63-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ To use this image with [Firebird Events](https://firebirdsql.org/file/documentat
144144
- [Publish](https://docs.docker.com/get-started/docker-concepts/running-containers/publishing-ports/) this port to the host.
145145

146146
More information:
147-
148147
- [This answer](https://stackoverflow.com/a/49918178/33244) from Mark Rotteveel at Stack Overflow.
149148
- [The Power of Firebird Events](https://www.firebirdsql.org/file/documentation/papers_presentations/Power_Firebird_events.pdf) from Milan Babuškov.
150149

@@ -156,7 +155,7 @@ When creating a new database with `FIREBIRD_DATABASE` environment variable you c
156155

157156
Any file with extensions `.sh`, `.sql`, `.sql.gz`, `.sql.xz` and `.sql.zst` found in `/docker-entrypoint-initdb.d/` will be executed in _alphabetical_ order. `.sh` files without file execute permission (`+x`) will be _sourced_ rather than executed.
158157

159-
**IMPORTANT:** Scripts will only run if you start the container with a data directory that is empty. Any pre-existing database will be left untouched on container startup.
158+
> **IMPORTANT:** Scripts will only run if you start the container with a data directory that is empty. Any pre-existing database will be left untouched on container startup.
160159

161160

162161

@@ -177,6 +176,68 @@ Alternatively, you can use the same time zone as your host system by mapping the
177176
- /etc/timezone:/etc/timezone:ro
178177
```
179178

179+
180+
181+
## Backup and Restore
182+
183+
### For online databases
184+
185+
If the database is in use, call `gbak` inside the running container using Firebird Service Manager (`-se` switch) for best performance.
186+
187+
The following commands will backup and restore a database **in the data directory** (`/var/lib/firebird/data`) of the running container.
188+
189+
```bash
190+
# Online backup
191+
FIREBIRD_CONTAINER=MY_CONTAINER_NAME_OR_ID
192+
DATABASE_FILE=MY_DATABASE.fdb
193+
BACKUP_FILE=MY_DATABASE.fbk
194+
195+
docker exec $FIREBIRD_CONTAINER bash -c "gbak -b -user SYSDBA -pas \$FIREBIRD_ROOT_PASSWORD -se localhost:service_mgr \$FIREBIRD_DATA/$DATABASE_FILE \$FIREBIRD_DATA/$BACKUP_FILE"
196+
```
197+
198+
```bash
199+
# Online restore
200+
FIREBIRD_CONTAINER=MY_CONTAINER_NAME_OR_ID
201+
BACKUP_FILE=MY_DATABASE.fbk
202+
DATABASE_FILE=MY_DATABASE.fdb
203+
204+
docker exec $FIREBIRD_CONTAINER bash -c "gbak -c -user SYSDBA -pas \$FIREBIRD_ROOT_PASSWORD -se localhost:service_mgr \$FIREBIRD_DATA/$BACKUP_FILE \$FIREBIRD_DATA/$DATABASE_FILE"
205+
```
206+
207+
208+
209+
### For offline databases
210+
211+
> **IMPORTANT:** > Never use this with online (running) database files.
212+
213+
If you don't have a running server, create an ephemeral container to run `gbak` directly over the database files.
214+
215+
The following commands will backup and restore a database **in the current directory** (`$PWD`).
216+
217+
```bash
218+
# Offline backup
219+
FIREBIRD_IMAGE=firebirdsql/firebird
220+
DATABASE_FILE=MY_DATABASE.fdb
221+
BACKUP_FILE=MY_DATABASE.fbk
222+
223+
docker run --rm -v .:/pwd $FIREBIRD_IMAGE gbak -b /pwd/$DATABASE_FILE /pwd/$BACKUP_FILE
224+
```
225+
226+
```bash
227+
# Offline restore
228+
FIREBIRD_IMAGE=firebirdsql/firebird
229+
BACKUP_FILE=MY_DATABASE.fbk
230+
DATABASE_FILE=MY_DATABASE.fdb
231+
232+
docker run --rm -v .:/pwd $FIREBIRD_IMAGE gbak -c /pwd/$BACKUP_FILE /pwd/$DATABASE_FILE
233+
```
234+
235+
More information:
236+
- [Firebird’s gbak Backup and Restore Utility](https://firebirdsql.org/file/documentation/html/en/firebirddocs/gbak/firebird-gbak.html) from Norman Dunbar and Mark Rotteveel.
237+
- [Quick Guide for Gbak Backup-Restore](https://ib-aid.com/articles/firebird-gbak-backup-tips-and-tricks) from IBSurgeon.
238+
239+
240+
180241
# Development notes
181242

182243
## Prerequisites

0 commit comments

Comments
 (0)