Database Management

Move to a different database or engine

Use cases:

  • move to a different database storage (e.g. provided by a different database host)

  • change the database engine (e.g. from SQLite to PostgreSQL)

  • migrate the data to a different host with a different database engine

Procedure:

  1. stop the running grouprise service (e.g. service grouprise stop)

  2. dump the current database content in a database-neutral format:

    grouprisectl dumpdata \
        --natural-primary \
        --natural-foreign \
        --exclude sessions \
        --exclude admin.logentry \
        --indent 4 \
        --all \
        >grouprise-export.json
    
  3. prepare the new desired configuration (below /etc/grouprise/conf.d/)

  4. create new database (see Database Initialization)

  5. populate the database structure: grouprisectl migrate

  6. load the export data: grouprisectl loaddata --format=json - <grouprise-export.json

  7. start the grouprise service (e.g. service grouprise start)

Import content into another host

Use cases:

  • migrate to a new deployment host

  • experiment with real production data in a local development setup

Please take a close look at the steps below and adjust these, before executing them. Your local database will be wiped completely.

Use grouprisectl instead of python3 manage.py, if the target setup is based on the deb-package of grouprise (instead of a local development checkout).

# delete the content of the local development database
python3 manage.py sqlflush | python3 manage.py dbshell
# repare the minimal database structure
python3 manage.py migrate
# export the live database content and import it into the local instance
ssh root@$GROUPRISE_HOST \
        grouprisectl dumpdata \
            --natural-primary
            --natural-foreign
            --exclude sessions
            --exclude admin.logentry
            --indent 4
            --all
    | python3 manage.py loaddata --format=json -

You may need to align your local configuration with the one of the remote host, if you enabled optional modules (e.g. matrix_chat).