refactor: Changed Paths for persistent Data

This commit is contained in:
Torben Brenner 2023-01-17 08:56:02 +01:00
parent 4efe356005
commit 1c3fa4fa3f
6 changed files with 19 additions and 22 deletions

View File

@ -128,8 +128,8 @@ All of the Bridgehead's outgoing connections are secured by transport encryption
- `/etc/bridgehead/traefik-tls` contains your Bridgehead's reverse proxies TLS certificates for [HTTPS access](#https-access).
- `/etc/bridgehead/pki` contains your Bridgehead's private key (e.g., but not limited to Samply.Beam), generated as part of the [Samply.Beam enrollment](#register-with-samplybeam).
- `/etc/bridgehead/trusted-ca-certs` contains third-party certificates to be trusted by the Bridgehead. For example, you want to place the certificates of your [TLS-terminating proxy](#network) here.
- `/var/data/bridgehead` contains persistent data of the bridgehead
- `/var/data/bridgehead/backups` contains automatically created backups of the databases.
- `/var/lib/bridgehead/data` contains persistent data of the bridgehead
- `/var/cache/bridgehead/backup` contains automatically created backups of the databases.
Your Bridgehead's actual data is not stored in the above directories, but in named docker volumes, see `docker volume ls` and `docker volume inspect <volume_name>`.

View File

@ -71,6 +71,6 @@ services:
POSTGRES_DB: "mainzelliste"
POSTGRES_PASSWORD: ${PATIENTLIST_POSTGRES_PASSWORD}
volumes:
- "/var/data/bridgehead/patientlist:/var/lib/postgresql/data"
# NOTE: Add backups here. This is only imported if /var/data/bridgehead/patientlist/ is empty!!!
- "/var/lib/bridgehead/data/patientlist:/var/lib/postgresql/data"
# NOTE: Add backups here. This is only imported if /var/lib/bridgehead/data/patientlist/ is empty!!!
- "/tmp/bridgehead/patientlist/:/docker-entrypoint-initdb.d/"

View File

@ -26,7 +26,7 @@ Upon configuration, the Bridgehead will spawn the following services:
- The `bridgehead-id-manager` at https://bridgehead.local/id-manager, provides a common interface for creating pseudonyms in the bridgehead.
- The `bridgehead-patientlist` at https://bridgehead.local/patientlist is a local instance of the open-source software [Mainzelliste](https://mainzelliste.de). This service's primary task is to map patients IDAT to pseudonyms identifying them along the different CCP projects.
- The `bridgehead-patientlist-db` is only accessible within the Bridgehead itself. This is a local postgresql instance storing the database for `bridgehead-patientlist`. The data is persisted in `/var/data/bridgehead/patientlist` and backups are automatically created in `/var/data/bridgehead/backups/bridgehead-patientlist-db`.
- The `bridgehead-patientlist-db` is only accessible within the Bridgehead itself. This is a local postgresql instance storing the database for `bridgehead-patientlist`. The data is persisted in `/var/lib/bridgehead/data/patientlist` and backups are automatically created in `/var/cache/bridgehead/backup/bridgehead-patientlist-db`.
### How to import an existing database (e.g from Legacy Windows or from Backups)
First you must shutdown your local bridgehead instance:
@ -36,10 +36,10 @@ systemctl stop bridgehead@ccp
Next you need to remove the current patientlist database:
```
rm -rf /var/data/bridgehead/patientlist
rm -rf /var/lib/bridgehead/data/patientlist
```
Third, you need to place your postgres dump in the import directory `/tmp/bridgehead/patientlist/some-dump.sql`. This will only be imported, then /var/data/bridgehead/patientlist is empty.
Third, you need to place your postgres dump in the import directory `/tmp/bridgehead/patientlist/some-dump.sql`. This will only be imported, then /var/lib/bridgehead/data/patientlist is empty.
> NOTE: Please create the postgres dump with the options "--no-owner" and "--no-privileges". Additionally ensure the dump is created in the plain format (SQL).
After this, you can restart your bridgehead and the dump will be imported:

View File

@ -24,7 +24,7 @@ services:
- "traefik.http.routers.mtba.tls=true"
volumes:
# This directory persists the FHIR Resources that are needed to import data into blaze.
- /var/data/bridgehead/mtba:/app/mtba-files/persist
- /var/lib/bridgehead/data/mtba:/app/mtba-files/persist
# Place new import files in this directory
- /tmp/bridgehead/mtba/:/app/mtba-files/input

View File

@ -22,8 +22,8 @@ Cmnd_Alias BRIDGEHEAD${PROJECT^^} = \\
/bin/systemctl stop bridgehead@${PROJECT}.service, \\
/bin/systemctl restart bridgehead@${PROJECT}.service, \\
/bin/systemctl restart bridgehead@*.service, \\
/bin/chown -R bridgehead /etc/bridgehead /srv/docker/bridgehead /var/data/bridgehead, \\
/usr/bin/chown -R bridgehead /etc/bridgehead /srv/docker/bridgehead /var/data/bridgehead
/bin/chown -R bridgehead /etc/bridgehead /srv/docker/bridgehead /var/lib/bridgehead /var/cache/bridgehead, \\
/usr/bin/chown -R bridgehead /etc/bridgehead /srv/docker/bridgehead /var/lib/bridgehead /var/cache/bridgehead
bridgehead ALL= NOPASSWD: BRIDGEHEAD${PROJECT^^}
EOF
@ -37,9 +37,14 @@ if [ -z "$LDM_PASSWORD" ]; then
echo -e "## Local Data Management Basic Authentication\n# User: $PROJECT\nLDM_PASSWORD=$generated_passwd" >> /etc/bridgehead/${PROJECT}.local.conf;
fi
log "INFO" "Creating directory /var/data/bridgehead for storage of persistent data."
mkdir -p /var/data/bridgehead
chown -R bridgehead /var/data/bridgehead
log "INFO" "Creating directory /var/lib/bridgehead for storage of persistent data."
mkdir -p /var/lib/bridgehead
chown -R bridgehead /var/lib/bridgehead
log "INFO" "Creating directory /var/cache/bridgehead for storage of backups."
mkdir -p /var/cache/bridgehead
chown -R bridgehead /var/cache/bridgehead
log "INFO" "Registering system units for bridgehead and bridgehead-update"
cp -v \

View File

@ -4,15 +4,7 @@ source lib/functions.sh
AUTO_BACKUP=${AUTO_BACKUP:-true}
if [ "$AUTO_BACKUP" == "true" ]; then
BACKUP_DIRECTORY="/var/data/bridgehead/backups"
if [ ! -d /var/data ]; then
log DEBUG "Created /var/data"
mkdir /var/data
fi
if [ ! -d /var/data/bridgehead ]; then
log DEBUG "Created /var/data/bridgehead"
mkdir /var/data/bridgehead
fi
BACKUP_DIRECTORY="/var/cache/bridgehead/backup"
if [ ! -d $BACKUP_DIRECTORY ]; then
message="Performing automatic maintenance: Creating Backup directory $BACKUP_DIRECTORY."
hc_send log "$message"