On the fly backup of FB DBs using async Firebird4 replication through SSH key secured to a container
1.2K
This Docker image provides Firebird 4.0.5 database server with built-in support for asynchronous replication through SSH tunnels. The image facilitates on-the-fly backups by replicating database files to a secondary container, all secured with SSH key encryption.
This Docker image is designed for:
The replication mechanism allows you to maintain up-to-date backups of your databases with minimal impact on performance. This makes it ideal for production environments where continuous operation is critical, but data safety cannot be compromised.
docker run -d \
--name firebird \
-p 3050:3050 \
-p 8122:8122 \
-e SSH_PORT=8122 \
-v /path/to/data:/firebird \
medaxsys/firebird:4.0.5
This will start a Firebird server with the default configuration. The server will:
/path/to/data on the host, which can be an encrypted volumeThis is your primary Firebird database server that runs your production databases.
docker run -d \
--name firebird-master \
-p 3050:3050 \
-p 8122:8122 \
-e SSH_PORT=8122 \
-v /path/to/master-data:/firebird \
medaxsys/firebird:4.0.5
This is your backup server that will receive replicated data.
docker run -d \
--name firebird-replica \
-p 3051:3050 \
-p 8123:8123 \
-e SSH_PORT=8123 \
-v /path/to/replica-data:/firebird \
medaxsys/firebird:4.0.5
The /firebird volume can be stored on an encrypted storage solution, such as within Azure Cloud's Container Instace.
The container automatically generates an SSH key pair on first startup. This key provides root access to the container via SSH.
Retrieve the SSH keys from the master:
Public key:
docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519.pub
Private key (to connect from external systems):
docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519
You may want to save the private key to a file on your host system:
docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519 > firebird_master_key
chmod 600 firebird_master_key
Add the public key to the replica's authorized keys:
# First, save the public key to a variable
PUBLIC_KEY=$(docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519.pub)
# Then add it to the replica's authorized keys
docker exec firebird-replica bash -c "mkdir -p /root/.ssh && echo \"$PUBLIC_KEY\" >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys"
Connect from an external system to the replica:
Once you have saved the private key, you can connect directly to the replica using the configured SSH port:
ssh -i firebird_master_key -p 8123 root@replica_host
Where replica_host is the hostname or IP address of your replica container host.
You can now establish SSH connections as the root user between containers or from an external system that has the private key.
When databases are replicated via SSH to this container, they will be automatically detected in the /firebird/data directory with names like replica_1.fdb, replica_2.fdb, etc. The container automatically creates corresponding journal directories named replica_1, replica_2, etc., in the same location.
Important: You can also deploy your replica databases by copying 7z archives to the /firebird/data directory. After restarting the container, these archives will be automatically unpacked. If the archive contains databases in the format replica_1.fdb - replica_x.fdb, the system will automatically configure journal directories (replica_1 - replica_x) to receive asynchronous replication journals via SSH.
The replication system handles:
replica_X.fdb)replica_X)The image comes with several utility scripts and tools:
Midnight Commander (mc): Pre-installed file manager for direct work within the container
docker exec -it firebird mc
sysdbapwd: Displays the current SYSDBA password
docker exec firebird sysdbapwd
replica2master: Converts a replica database to a master database
docker exec firebird replica2master
create_restore: Creates master databases from replicas and packages them for restoration
docker exec firebird create_restore
restart_container: Gracefully restarts the container
docker exec firebird restart_container
When you need to restore a database from the replica:
Run the create_restore command on the replica container:
docker exec firebird-replica create_restore
This will create a compressed file /firebird/data/restore_dbs.7z containing converted master databases.
Extract and use these databases as needed.
ISC_PASSWORD: Set a specific password for the SYSDBA user (if not set, a random password will be generated)SSH_PORT: Set a custom port for SSH connections (defaults to 22 if not specified)EnableLegacyClientAuth: Set to 'true' to enable legacy authenticationEnableWireCrypt: Set to 'true' to enforce wire encryptionDataTypeCompatibility: Set compatibility mode for data types/firebird: Main directory containing Firebird configuration, databases, journal files, and logsTento Docker image je navržen pro:
Replikační mechanismus umožňuje udržovat aktuální zálohy vašich databází s minimálním dopadem na výkon. To je ideální pro produkční prostředí, kde je kritický nepřetržitý provoz, ale bezpečnost dat nemůže být ohrožena.
docker run -d \
--name firebird \
-p 3050:3050 \
-p 8122:8122 \
-e SSH_PORT=8122 \
-v /cesta/k/datum:/firebird \
medaxsys/firebird:4.0.5
Toto spustí server Firebird s výchozí konfigurací. Server bude:
/cesta/k/datum na hostiteli, což může být šifrovaný svazekToto je váš primární databázový server Firebird, který provozuje vaše produkční databáze.
docker run -d \
--name firebird-master \
-p 3050:3050 \
-p 8122:8122 \
-e SSH_PORT=8122 \
-v /cesta/k/master-data:/firebird \
medaxsys/firebird:4.0.5
Toto je váš záložní server, který bude přijímat replikovaná data.
docker run -d \
--name firebird-replica \
-p 3051:3050 \
-p 8123:8123 \
-e SSH_PORT=8123 \
-v /cesta/k/replica-data:/firebird \
medaxsys/firebird:4.0.5
Svazek /firebird může být uložen na šifrovaném úložišti, například v rámci služby Container Instace v Azure Cloud.
Kontejner automaticky generuje pár SSH klíčů při prvním spuštění. Tento klíč poskytuje root přístup ke kontejneru přes SSH.
Získání SSH klíčů z master kontejneru:
Veřejný klíč:
docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519.pub
Privátní klíč (pro připojení z externích systémů):
docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519
Můžete si uložit privátní klíč do souboru na hostitelském systému:
docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519 > firebird_master_key
chmod 600 firebird_master_key
Přidání veřejného klíče do autorizovaných klíčů repliky:
# Nejprve uložte veřejný klíč do proměnné
PUBLIC_KEY=$(docker exec firebird-master cat /firebird/etc/sshkey/id_ed25519.pub)
# Poté jej přidejte do autorizovaných klíčů repliky
docker exec firebird-replica bash -c "mkdir -p /root/.ssh && echo \"$PUBLIC_KEY\" >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys"
Připojení z externího systému k replice:
Jakmile máte uložený privátní klíč, můžete se připojit přímo k replice s použitím nakonfigurovaného SSH portu:
ssh -i firebird_master_key -p 8123 root@replica_host
Kde replica_host je hostname nebo IP adresa hostitele vašeho kontejneru s replikou.
Nyní můžete navázat SSH připojení jako uživatel root mezi kontejnery nebo z externího systému, který má privátní klíč.
Když jsou databáze replikovány přes SSH do tohoto kontejneru, budou automaticky detekovány v adresáři /firebird/data s názvy jako replica_1.fdb, replica_2.fdb, atd. Kontejner automaticky vytvoří odpovídající adresáře žurnálů s názvy replica_1, replica_2, atd., ve stejném umístění.
Důležité: Můžete také nasadit replikační databáze zkopírováním 7z archivů do adresáře /firebird/data. Po restartu kontejneru budou tyto archivy automaticky rozbaleny. Pokud archiv obsahuje databáze ve formátu replica_1.fdb - replica_x.fdb, systém automaticky nakonfiguruje adresáře žurnálů (replica_1 - replica_x) pro příjem žurnálů asynchronní replikace přes SSH.
Replikační systém spravuje:
replica_X.fdb)replica_X)Image obsahuje několik utilit a nástrojů:
Midnight Commander (mc): Předinstalovaný správce souborů pro přímou práci v kontejneru
docker exec -it firebird mc
sysdbapwd: Zobrazí aktuální heslo uživatele SYSDBA
docker exec firebird sysdbapwd
replica2master: Převede replikační databázi na hlavní databázi
docker exec firebird replica2master
create_restore: Vytvoří hlavní databáze z replik a zabalí je pro obnovu
docker exec firebird create_restore
restart_container: Elegantně restartuje kontejner
docker exec firebird restart_container
Když potřebujete obnovit databázi z repliky:
Spusťte příkaz create_restore na kontejneru repliky:
docker exec firebird-replica create_restore
Tím se vytvoří komprimovaný soubor /firebird/data/restore_dbs.7z obsahující převedené hlavní databáze.
Rozbalte a použijte tyto databáze podle potřeby.
ISC_PASSWORD: Nastavení konkrétního hesla pro uživatele SYSDBA (pokud není nastaveno, vygeneruje se náhodné heslo)SSH_PORT: Nastavení vlastního portu pro SSH připojení (výchozí hodnota je 22, pokud není specifikováno)EnableLegacyClientAuth: Nastavte na 'true' pro povolení starší autentizaceEnableWireCrypt: Nastavte na 'true' pro vynucení šifrování přenosuDataTypeCompatibility: Nastavení režimu kompatibility pro datové typy/firebird: Hlavní adresář obsahující konfiguraci Firebird, databáze, soubory žurnálů a logyContent type
Image
Digest
sha256:8ec34fcec…
Size
181.9 MB
Last updated
over 1 year ago
docker pull medaxtn/fb_repl_azure