Storage System
SirrChat provides flexible storage options, supporting multiple storage backends from local filesystems to cloud object storage.
Storage Types
Local Storage
The simplest storage method, suitable for single-server deployments.
toml
[storage]
type = "local"
local_path = "/var/mail"S3-Compatible Storage
Supports AWS S3 and all S3-compatible object storage.
toml
[storage]
type = "s3"
[storage.s3]
endpoint = "s3.amazonaws.com"
region = "us-east-1"
bucket = "sirrchat-storage"
access_key = "YOUR_ACCESS_KEY"
secret_key = "YOUR_SECRET_KEY"MinIO
Open source S3-compatible storage.
toml
[storage.s3]
endpoint = "minio.example.com:9000"
bucket = "sirrchat"
access_key = "minioadmin"
secret_key = "minioadmin"
use_ssl = falseDatabase Storage
PostgreSQL
Recommended for production environments.
toml
[database]
type = "postgres"
dsn = "postgresql://user:password@localhost:5432/sirrchat?sslmode=require"
# Connection pool configuration
max_open_conns = 25
max_idle_conns = 5
conn_max_lifetime = "5m"MySQL/MariaDB
Widely used relational database.
toml
[database]
type = "mysql"
dsn = "user:password@tcp(localhost:3306)/sirrchat?parseTime=true&charset=utf8mb4"SQLite
Suitable for development and small-scale deployments.
toml
[database]
type = "sqlite"
dsn = "/var/lib/sirrchatd/sirrchat.db"Email Storage Format
Maildir
Standard email storage format, one file per email.
/var/mail/user@example.com/
├── cur/ # Read emails
├── new/ # New emails
└── tmp/ # Temporary filesFile Naming
1642123456.M123456P12345.hostname,S=1234:2,S- Timestamp
- Unique ID
- Size
- Flags (read, replied, etc.)
Storage Optimization
Compression
Automatically compress old emails to save space.
toml
[storage.compression]
enabled = true
algorithm = "gzip" # gzip, bzip2, zstd
min_age_days = 30 # Compress after 30 daysDeduplication
Automatically detect and remove duplicate emails.
toml
[storage.deduplication]
enabled = true
hash_algorithm = "sha256"Tiered Storage
Automatically migrate data based on access frequency.
toml
[storage.tiering]
enabled = true
# Hot storage: frequently accessed
[storage.tiering.hot]
type = "local"
path = "/fast/ssd/mail"
max_age_days = 30
# Cold storage: archival
[storage.tiering.cold]
type = "s3"
bucket = "sirrchat-archive"Quota Management
User Quotas
toml
[storage.quota]
default_quota = "1GB"
max_quota = "10GB"
warning_threshold = 90 # Warn at 90%Set User Quota
bash
sirrchatd quota set --user user@example.com --quota 5GBView Quota Usage
bash
sirrchatd quota get --user user@example.comBackup and Recovery
Automatic Backup
toml
[storage.backup]
enabled = true
schedule = "0 2 * * *" # Daily at 2 AM
retention_days = 30
[storage.backup.destination]
type = "s3"
bucket = "sirrchat-backups"Manual Backup
bash
# Backup all data
sirrchatd backup create --output /backups/sirrchat-$(date +%Y%m%d).tar.gz
# Backup specific user
sirrchatd backup create --user user@example.comRestore Data
bash
# Restore all data
sirrchatd backup restore --input /backups/sirrchat-20250115.tar.gz
# Restore specific user
sirrchatd backup restore --user user@example.com --input backup.tar.gzData Migration
Migrate from Other Mail Servers
From Postfix/Dovecot
bash
sirrchatd migrate --from maildir --source /var/mail/vhostsFrom Exchange
bash
sirrchatd migrate --from pst --source /exports/*.pstStorage Backend Migration
Migrate from local to S3:
bash
sirrchatd storage migrate --from local --to s3Monitoring and Maintenance
Storage Usage Statistics
bash
sirrchatd storage statsOutput:
Total Size: 125.5 GB
Users: 1,234
Average per User: 104.2 MB
Largest User: user@example.com (5.2 GB)Cleanup Operations
Delete Expired Emails
bash
sirrchatd cleanup --older-than 2yClean Trash
bash
sirrchatd cleanup --trash --older-than 30dClean Temporary Files
bash
sirrchatd cleanup --tempPerformance Optimization
Cache Configuration
toml
[storage.cache]
enabled = true
size_mb = 512
ttl = "1h"Index Optimization
toml
[storage.indexing]
enabled = true
full_text_search = trueConcurrency Control
toml
[storage.concurrency]
max_workers = 10
queue_size = 1000Data Security
Encryption
Transfer Encryption
toml
[storage.encryption]
# S3 transfer encryption
s3_use_tls = trueEncryption at Rest
toml
[storage.encryption]
enabled = true
algorithm = "AES-256-GCM"
key_file = "/etc/sirrchatd/encryption.key"Access Control
toml
[storage.access]
# Restrict access paths
allow_paths = ["/var/mail"]
deny_paths = ["/etc", "/root"]High Availability
Replication
Master-Slave Replication
toml
[storage.replication]
mode = "master"
slaves = ["slave1.example.com", "slave2.example.com"]Multi-Master Replication
toml
[storage.replication]
mode = "multi-master"
peers = ["peer1.example.com", "peer2.example.com"]Failover
toml
[storage.failover]
enabled = true
health_check_interval = "30s"
auto_failover = trueTroubleshooting
Diagnostic Tools
bash
# Check storage connection
sirrchatd storage test
# Verify data integrity
sirrchatd storage verify
# Repair corrupted mailboxes
sirrchatd storage repair --user user@example.comCommon Issues
Disk Space Insufficient
bash
# Clean old emails
sirrchatd cleanup --older-than 1y
# Compress emails
sirrchatd storage compressS3 Connection Failed
bash
# Test S3 connection
sirrchatd storage test --type s3
# View detailed errors
sirrchatd storage test --debugRelated documentation: