-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: postgres: add multiple database functionality
This commit contains the necessary changes to implement a multiple same-database system, utilizing a linked-list. Each linked list represents a database system, with each node being a different database. Changelog: - For each section parsed in the config file, create a node. If the config contains multiple of the same section, i.e. multiple databases of the same type, then allocate memory for a new node that will hold the config for each database. - Changed `db_t` struct to take a `void *` argument instead of a specific database structure, and also change some functions in a similar way. This change was necessary in order to leverage generic programming for the main functions (connect, replicate, close). - Added some helper function for the linked list. - Added more thread safe functionality to critical sections of the codebase. - Changed the structure of the `configs` file, added `.ini` files for testing single/multple databases Signed-off-by: Panagiotis Foliadis <pfoliadis@hotmail.com> Co-developed-by: Charalampos Mitrodimas <charmitro@posteo.net>
- Loading branch information
Showing
17 changed files
with
366 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[general] | ||
log_filepath= | ||
|
||
[postgres] | ||
enabled= | ||
|
||
origin_host= | ||
origin_user= | ||
origin_password= | ||
origin_port= | ||
origin_database= | ||
|
||
target_host= | ||
target_user= | ||
target_password= | ||
target_port= | ||
target_database= | ||
|
||
backup_type= | ||
email= | ||
|
||
[smtp] | ||
username= | ||
password= | ||
smtp_host= | ||
smtp_port= | ||
auth_mode= | ||
enabled= | ||
|
||
from= | ||
to= | ||
cc= |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[postgres] | ||
enabled=true | ||
|
||
origin_host=localhost | ||
origin_user=postgres | ||
origin_password=password | ||
origin_port=5432 | ||
origin_database=postgres_origin | ||
|
||
target_host=localhost | ||
target_user=postgres | ||
target_password=password | ||
target_port=5432 | ||
target_database=postgres_origin | ||
|
||
backup_type=full | ||
email=false | ||
|
||
[postgres] | ||
enabled=true | ||
|
||
origin_host=localhost | ||
origin_user=postgres | ||
origin_password=password | ||
origin_port=5433 | ||
origin_database=postgres_origin | ||
|
||
target_host=localhost | ||
target_user=postgres | ||
target_password=password | ||
target_port=5433 | ||
target_database=postgres_origin | ||
|
||
backup_type=full | ||
email=false | ||
|
||
[smtp] | ||
username = test@posteo.net | ||
password = 123 | ||
smtp_host = posteo.de | ||
smtp_port = 587 | ||
auth_mode = tls | ||
enabled=true | ||
|
||
from = charmitro@posteo.net | ||
to = charmitro@pm.me, trsbisb@gmail.com | ||
cc = charmitro@gmail.com, charmitro@terrasync.net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
#! /bin/bash | ||
|
||
if docker ps --format "{{.Names}}" | grep -q "cnc-postgres"; then | ||
docker stop cnc-postgres | ||
docker rm cnc-postgres | ||
echo "PostgreSQL Docker container was successfully removed." | ||
if docker ps --format "{{.Names}}" | grep -q "cnc-postgres-origin"; then | ||
docker stop cnc-postgres-origin | ||
docker rm cnc-postgres-origin | ||
echo "Postgres-origin docker container was successfully removed." | ||
else | ||
echo "PostgreSQL Docker container is not currently running." | ||
echo "Postgre-origin docker container is not currently running." | ||
fi | ||
|
||
if docker ps --format "{{.Names}}" | grep -q "cnc-postgres-target"; then | ||
docker stop cnc-postgres-target | ||
docker rm cnc-postgres-target | ||
echo "Postgres-target docker container was successfully removed." | ||
else | ||
echo "Postgres-target docker container is not currently running." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.