Skip to main content

Database migration

On host running the APP module:

  1. End or wait for all active scans to complete.

  2. Stop the application server:

    sudo systemctl stop derscanner-app
  3. Do a database dump:

    sudo docker exec app-db pg_dump -U backend backend > db_dump.sql
  4. Memorize or write down the value of the hibernate.connection.password field in /opt/derscanner/app/configs/backend.env.

On Host_2 where you want to deploy the PostgreSQL DBMS:

  1. Install PostgreSQL DBMS version 13.0 or higher.

  2. Create a user in the database with the name backend and the password from the hibernate.connection.password field.

  3. Create an empty database named backend from the user named backend:

    • for host: sudo createdb -p 5432 -h localhost -U backend backend (may require the user postgres, sudo su - posrgres)
    • for Docker: sudo docker exec <Container_Name> createdb -p 5432 -h localhost -U backend backend
  4. Create a database dump (db_dump.sql) into an empty database:

    • for host: sudo cat db_dump. sql sudo psql -p 5432 -h localhost -U backend -d backend (may require postgres user, sudo su - posrgres)
    • for Docker: sudo cat db_dump.sql | sudo docker exec -i \<CONTAINER_NAME\> psql -p 5432 -h localhost -U backend -d backend
  5. Make the connection to the server available externally.

On host with the APP module:

  1. Open the /opt/derscanner/app/configs/backend.env file for editing.

  2. Change hibernate.connection.url=jdbc:postgresql:/app-db:5432/backend?ssl=falsee changing the name of the app-db container connection to the address of the server with the deployed database, for example: hibernate.connection.url=jdbc:postgresql:/####.###.#.####:####/backend?ssl=falsee.

  3. Save the changes and start the application service:

    sudo systemctl start derscanner-app