A Docker image combining n8n workflow automation with PostgreSQL client tools, including pg_dump for database backups.
# Create directories
mkdir -p backups workflows
# Run with docker-compose
curl -o docker-compose.yml https://raw.githubusercontent.com/your-repo/docker-compose-hub.yml
docker-compose up -d
# Create directories
mkdir -p backups workflows
# Download production compose file
curl -o docker-compose.yml https://raw.githubusercontent.com/your-repo/docker-compose-production.yml
docker-compose up -d
docker run -d \
--name n8n-pgdump \
-p 5678:5678 \
-v n8n_data:/home/node/.n8n \
-v ./backups:/backups \
-e N8N_BASIC_AUTH_ACTIVE=true \
-e N8N_BASIC_AUTH_USER=admin \
-e N8N_BASIC_AUTH_PASSWORD=admin \
aidencro/n8n-pgdump:latest
pg_dump - Database backup utilitypsql - Interactive PostgreSQL clientpg_restore - Database restoration utility| Variable | Default | Description |
|---|---|---|
N8N_BASIC_AUTH_ACTIVE | true | Enable basic authentication |
N8N_BASIC_AUTH_USER | admin | Basic auth username |
N8N_BASIC_AUTH_PASSWORD | admin | Basic auth password |
| Variable | Default | Description |
|---|---|---|
DB_TYPE | sqlite | Database type (sqlite, postgresdb, mysqldb) |
DB_POSTGRESDB_HOST | - | PostgreSQL host |
DB_POSTGRESDB_PORT | 5432 | PostgreSQL port |
DB_POSTGRESDB_DATABASE | - | PostgreSQL database name |
DB_POSTGRESDB_USER | - | PostgreSQL username |
DB_POSTGRESDB_PASSWORD | - | PostgreSQL password |
| Variable | Default | Description |
|---|---|---|
WEBHOOK_URL | http://localhost:5678/ | Webhook URL for n8n |
N8N_ENCRYPTION_KEY | - | Encryption key for sensitive data |
N8N_HOST | 0.0.0.0 | Host to bind n8n server |
N8N_PORT | 5678 | Port for n8n web interface |
| Path | Description |
|---|---|
/home/node/.n8n | n8n data directory (workflows, credentials, settings) |
/backups | Directory for database backups |
/workflows | Optional: Import/export workflows |
services:
n8n:
image: aidencro/n8n-pgdump:latest
container_name: n8n-pgdump
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=admin
volumes:
- n8n_data:/home/node/.n8n
- ./backups:/backups
restart: unless-stopped
volumes:
n8n_data:
services:
postgres:
image: postgres:16-alpine
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=secure_password
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: aidencro/n8n-pgdump:latest
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=secure_password
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=secure_admin_password
volumes:
- n8n_data:/home/node/.n8n
- ./backups:/backups
depends_on:
- postgres
volumes:
n8n_data:
postgres_data:
Use the "Execute Command" node in n8n workflows:
Command:
pg_dump -h database_host -U username -d database_name > /backups/backup_$(date +%Y%m%d_%H%M%S).sql
# Enter container
docker exec -it n8n-pgdump sh
# Create backup
pg_dump -h your-db-host -U username -d database > /backups/backup.sql
# With compression
pg_dump -h your-db-host -U username -d database | gzip > /backups/backup.sql.gz
Create an n8n workflow with a cron trigger:
Change Default Passwords
environment:
- N8N_BASIC_AUTH_USER=your_username
- N8N_BASIC_AUTH_PASSWORD=your_secure_password
Use Strong Encryption Key
environment:
- N8N_ENCRYPTION_KEY=your-very-long-random-encryption-key
Limit Network Access
ports:
- "127.0.0.1:5678:5678" # Only localhost access
Use Secrets Management
docker secret create n8n_encryption_key encryption_key.txt
services:
n8n:
image: aidencro/n8n-pgdump:latest
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:5678/healthz"]
interval: 30s
timeout: 10s
retries: 3
# Check container stats
docker stats n8n-pgdump
# Check logs
docker logs n8n-pgdump -f
services:
n8n:
image: aidencro/n8n-pgdump:latest
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
reservations:
memory: 256M
cpus: '0.25'
services:
n8n-main:
image: aidencro/n8n-pgdump:latest
command: n8n start
# ... other config
n8n-worker:
image: aidencro/n8n-pgdump:latest
command: n8n worker
# ... other config
Container won't start:
docker logs n8n-pgdump
Permission issues with volumes:
sudo chown -R 1000:1000 ./backups
sudo chmod 755 ./backups
Database connection issues:
environment:
- N8N_LOG_LEVEL=debug
This image is based on the official n8n image and includes PostgreSQL client tools. Please refer to the respective licenses:
Content type
Image
Digest
sha256:1e7ec6ddf…
Size
274.7 MB
Last updated
about 1 year ago
docker pull aidencro/n8n-pgdump