If you have a database dump to import (e.g., for testing or restoring data), follow these steps:
Before importing a database dump, ensure that your Ozma application is fully deployed and operational.
You can copy the dump file to your server using scp
or download it directly on the server using curl
:
curl -LO 'https://your-dump-url/ozmadb.pg_dump'
If the containers are not already running, start them:
docker compose up -d
Run the following command to drop and recreate the databases:
docker compose exec -T postgres psql -U postgres <<< '
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pid <> pg_backend_pid() AND datname IS NOT NULL;
DROP DATABASE "ozmadb";
CREATE DATABASE "ozmadb" OWNER "ozmadb";
\c ozmadb
ALTER SCHEMA public OWNER TO "ozmadb";
DROP DATABASE "ozma-report-generator";
CREATE DATABASE "ozma-report-generator" OWNER "ozma-report-generator";
\c ozma-report-generator
ALTER SCHEMA public OWNER TO "ozma-report-generator";
'
Note: If you modify the .env
file after the initial setup, you need to remove existing containers and volumes to apply the changes:
docker compose down -v
docker compose up -d
Restore the Ozma database:
docker compose exec -T postgres pg_restore -U ozmadb -d ozmadb -xO < path/to/ozmadb.pg_dump
If you are using the Report Generator, restore its database as well:
docker compose exec -T postgres pg_restore -U ozma-report-generator -d ozma-report-generator -xO < path/to/report-generator.pg_dump
After restoring the databases, you should be able to access the Ozma application at your domain and see your data.