Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL backup/restore (WIP) #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions 60-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ else
DBHOST=db
$omero config set omero.db.host "$DBHOST"
fi

CONFIG_omero_db_name=${CONFIG_omero_db_name:-}
if [ -n "$CONFIG_omero_db_name" ]; then
DBNAME="$CONFIG_omero_db_name"
DBNAME_src=env
else
# Delay setting in config until *after*
# the upgrade is attempted.
DBNAME=omero
DBNAME_src=default
fi

DBUSER="${CONFIG_omero_db_user:-omero}"
DBNAME="${CONFIG_omero_db_name:-omero}"
DBPASS="${CONFIG_omero_db_pass:-omero}"
ROOTPASS="${ROOTPASS:-omero}"

Expand All @@ -39,7 +50,18 @@ psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \
"select * from dbpatch" 2> /dev/null && {
echo "Upgrading database"
$omego db upgrade --serverdir=OMERO.server
} || {
echo "Initialising database"
$omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server
}
} || {

if [ "$DBNAME_src" = default ]; then
$omero config set omero.db.name "$DBNAME"
fi

if [ -f "/opt/omero/sql/db.sql" ]; then
echo "Restoring database"
$omego db init --omerosql "/opt/omero/sql/db.sql" --serverdir=OMERO.server
else
echo "Initialising database"
$omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server
fi

}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ RUN curl -L -o /usr/local/bin/dumb-init \
ADD entrypoint.sh /usr/local/bin/
ADD 50-config.py 60-database.sh 99-run.sh /startup/

RUN mkdir -p /opt/omero/sql && \
chown omero-server:omero-server /opt/omero/sql

USER omero-server

EXPOSE 4063 4064
Expand Down