Portabase AgentDatabases
MongoDB
Configuration for MongoDB.
The agent will use mongodump to perform backups and mongorestore to restore backups.
Configuration
When running portabase db add, select mongodb as the database type.
In your databases.json (or .toml) file, configure the following block.
With Authentication
{
"name": "Database - MongoDB Auth",
"database": "testdbauth",
"type": "mongodb",
"username": "username",
"password": "password",
"port": 27017,
"host": "db-mongodb-auth",
"generated_id": "..."
}Without Authentication
{
"name": "my-mongo",
"type": "mongodb",
"host": "db-mongodb",
"port": 27017,
"database": "testdb",
"generated_id": "..."
}Generate UUID for your configuration
Generating...Docker Compose Example
Example with a MongoDB image.
services:
db-mongodb-auth:
container_name: db-mongodb-auth
image: mongo:latest
ports:
- "27082:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: rootpassword
MONGO_INITDB_DATABASE: testdbauth
command: mongod --auth
networks:
- portabase
volumes:
- mongodb-data-auth:/data/db
healthcheck:
test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
interval: 5s
timeout: 5s
retries: 10
db-mongodb:
container_name: db-mongodb
image: mongo:latest
ports:
- "27083:27017"
volumes:
- mongodb-data:/data/db
healthcheck:
test: [ "CMD", "mongosh", "--eval", "db.adminCommand('ping')" ]
interval: 5s
timeout: 5s
retries: 10
environment:
MONGO_INITDB_DATABASE: testdb
networks:
- portabase
agent:
image: portabase/agent:latest
# ... agent configuration ...
depends_on:
- db-mongodb
- db-mongodb-auth
networks:
- portabase
networks:
portabase:
external: true
volumes:
mongodb-data:
mongodb-data-auth:If you use localhost as the host (because the agent is on the host machine and not in Docker, or via host-gateway), ensure your database is listening on all interfaces (0.0.0.0) or is accessible from the agent.
Last updated on