Sign inSign up

aidencro/n8n-pgdump

By aidencro

•Updated about 1 year ago

Image
0

1.2K

aidencro/n8n-pgdump repository overview

⁠ontent ready to copy to Docker Hub:

⁠n8n with pg_dump - Docker Image

Docker Image Version Docker Image Size Docker Pulls

A Docker image combining n8n⁠ workflow automation with PostgreSQL client tools, including pg_dump for database backups.

⁠🚀 Quick Start

⁠Simple Setup (SQLite)
# 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
⁠Production Setup (PostgreSQL)
# 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
⁠Direct Docker Run
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

⁠📋 Features

  • ✅ n8n Workflow Automation - Full n8n platform for workflow automation
  • ✅ PostgreSQL Client Tools - Complete PostgreSQL client suite including:
    • pg_dump - Database backup utility
    • psql - Interactive PostgreSQL client
    • pg_restore - Database restoration utility
    • All other PostgreSQL client tools
  • ✅ Production Ready - Optimized for production use
  • ✅ Multi-Architecture - Supports AMD64 and ARM64

⁠🔧 Environment Variables

⁠Authentication
VariableDefaultDescription
N8N_BASIC_AUTH_ACTIVEtrueEnable basic authentication
N8N_BASIC_AUTH_USERadminBasic auth username
N8N_BASIC_AUTH_PASSWORDadminBasic auth password
⁠Database Configuration
VariableDefaultDescription
DB_TYPEsqliteDatabase type (sqlite, postgresdb, mysqldb)
DB_POSTGRESDB_HOST-PostgreSQL host
DB_POSTGRESDB_PORT5432PostgreSQL port
DB_POSTGRESDB_DATABASE-PostgreSQL database name
DB_POSTGRESDB_USER-PostgreSQL username
DB_POSTGRESDB_PASSWORD-PostgreSQL password
⁠n8n Configuration
VariableDefaultDescription
WEBHOOK_URLhttp://localhost:5678/Webhook URL for n8n
N8N_ENCRYPTION_KEY-Encryption key for sensitive data
N8N_HOST0.0.0.0Host to bind n8n server
N8N_PORT5678Port for n8n web interface

⁠📁 Volumes

PathDescription
/home/node/.n8nn8n data directory (workflows, credentials, settings)
/backupsDirectory for database backups
/workflowsOptional: Import/export workflows

⁠🐳 Docker Compose Examples

⁠Simple SQLite Setup
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:
⁠Production with PostgreSQL
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:

⁠🛠️ Using pg_dump

⁠In n8n Workflows

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
⁠Manual Backup
# 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
⁠Automated Backups

Create an n8n workflow with a cron trigger:

  1. Cron Trigger - Schedule backups (e.g., daily at 2 AM)
  2. Execute Command - Run pg_dump
  3. Email/Slack - Send notification on success/failure

⁠🔐 Security Best Practices

  1. Change Default Passwords

    environment:
      - N8N_BASIC_AUTH_USER=your_username
      - N8N_BASIC_AUTH_PASSWORD=your_secure_password
    
  2. Use Strong Encryption Key

    environment:
      - N8N_ENCRYPTION_KEY=your-very-long-random-encryption-key
    
  3. Limit Network Access

    ports:
      - "127.0.0.1:5678:5678"  # Only localhost access
    
  4. Use Secrets Management

    docker secret create n8n_encryption_key encryption_key.txt
    

⁠📊 Monitoring & Health Checks

⁠Health Check
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
⁠Resource Monitoring
# Check container stats
docker stats n8n-pgdump

# Check logs
docker logs n8n-pgdump -f

⁠🚀 Scaling & Performance

⁠Resource Limits
services:
  n8n:
    image: aidencro/n8n-pgdump:latest
    deploy:
      resources:
        limits:
          memory: 512M
          cpus: '0.5'
        reservations:
          memory: 256M
          cpus: '0.25'
⁠Multiple Workers
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

⁠🐛 Troubleshooting

⁠Common Issues

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:

  • Ensure database is accessible from container
  • Check network connectivity
  • Verify credentials
⁠Debug Mode
environment:
  - N8N_LOG_LEVEL=debug

⁠📚 Additional Resources

⁠📝 License

This image is based on the official n8n image and includes PostgreSQL client tools. Please refer to the respective licenses:

Tag summary

Content type

Image

Digest

sha256:1e7ec6ddf…

Size

274.7 MB

Last updated

about 1 year ago

docker pull aidencro/n8n-pgdump