This repository contains the configs and scripts used to run the WB Apollo server.
New instances are current set up manually. To setup a new instance (for OS upgrades, machine replacement etc.):
- Start a new machine (any linux OS)
- Install docker (if not pre-installed)
- Copy the docker-compose.yml and the apollo-service-commons.yml files onto the machine.
- Migrate the data if required (see below)
- Start the appolo server daemon (if not already done so during data migration):
docker compose up -d wb-apollo-server
To migrate/restore all data from another Apollo instance to a new instance, to be used by the Apollo service defined in this repository, do the following steps:
- Create a snapshot of the data volume attached to the old instance (on which the jbrowse data files are stored).
- If the (postgres) DBs on the old instance are not stored on the data volume, make DB dumps of the appollo DB and the chado DB on it:
$ sudo -u postgres pg_dump --format=c -d apollo-release-production > apollo-release-production_dump.pg_dump $ sudo -u postgres pg_dump --format=c -d apollo-production-chado > apollo-production-chado_dump.pg_dump
- Transfer the dump files to the new machine if generated, store them in the
./apollo_backups
directory (create the directory if needed). - Once the snapshot from step 1 completed, restore it as a new volume and attach it to the new instance.
- Mount the new volume (assumed attachment on
/dev/sdg
and OS Ubuntu):$ mount /dev/xvdg /data
- If the root of this volume contains the JBrowse data files (subfolders for each species, rather than JBrowse/Postgres/Apollo data separation),
reorganise the data on it (on the new instance):
- All JBrowse data folders go in a folder
/data/jbrowse_data
$ cd /data $ mkdir jbrowse_data/ $ mv * jbrowse_data/
- Make an empty folder
/data/temp_apollo_data
, for temporary apollo files. - Make a empty folder
/data/postgres_data
, for permanent postgres DB storage.
- All JBrowse data folders go in a folder
- Export all required environment variables with the appropiate DB credentials
(see the appollo-service-commons.yml file for a list of variables used).
Use an extra space before each export command so the secrets don't get stored to bash history (
export VAR_NAME=secret
). - On the new instance, start the apollo container:
Let it complete startup (to create the necessary DB roles), then stop the process (ctrl+C or cmd+.)
$ docker compose up wb-apollo-server
- Open a terminal into an appollo service container, with all data volumes mounted:
$ docker compose run apollo-import-export
- In this container, start the postgres server.
/usr/lib/postgresql/9.6/bin/pg_ctl -D /var/lib/postgresql/9.6/main -w start
- Drop and restore the main postgres database.
dropdb $WEBAPOLLO_DB_NAME createdb -E UTF-8 -O $WEBAPOLLO_DB_USERNAME $WEBAPOLLO_DB_NAME pg_restore -d $WEBAPOLLO_DB_NAME ./apollo_backups/apollo-release-production.pg_dump
- Drop and restore the chado postgres database.
dropdb $CHADO_DB_NAME createdb -E UTF-8 -O $CHADO_DB_USERNAME $CHADO_DB_NAME pg_restore -d $CHADO_DB_NAME ./apollo_backups/apollo-production-chado.pg_dump
- Exit the import/export container (ctrl+d) and start the apollo service again
(this time in the background).
docker compose up -d wb-apollo-server
- The Apollo server will attempt a database schema migration when needed.
Inspect the logs for the error documented here.
If the error occured, patch the CHADO database manually:
docker exec -it wb.apollo.server psql -c "ALTER TABLE chadoprop ADD COLUMN cvterm_id int8 not null DEFAULT 1" docker compose restart wb-apollo-server