Skip to content

Storage System ​

SirrMesh 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 = false

Database 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/sirrmeshd/sirrchat.db"

Mail Storage Format ​

Maildir ​

Standard mail storage format, one file per email.

/var/mail/[email protected]/
  ├── cur/     # Read emails
  ├── new/     # New emails
  └── tmp/     # Temporary files

File 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 days

Deduplication ​

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
sirrmeshd quota set --user [email protected] --quota 5GB

View Quota Usage ​

bash
sirrmeshd quota get --user [email protected]

Backup 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
sirrmeshd backup create --output /backups/sirrchat-$(date +%Y%m%d).tar.gz

# Backup specific user
sirrmeshd backup create --user [email protected]

Restore Data ​

bash
# Restore all data
sirrmeshd backup restore --input /backups/sirrchat-20250115.tar.gz

# Restore specific user
sirrmeshd backup restore --user [email protected] --input backup.tar.gz

Data Migration ​

Migrate from Other Mail Servers ​

From Postfix/Dovecot ​

bash
sirrmeshd migrate --from maildir --source /var/mail/vhosts

From Exchange ​

bash
sirrmeshd migrate --from pst --source /exports/*.pst

Storage Backend Migration ​

Migrate from local to S3:

bash
sirrmeshd storage migrate --from local --to s3

Monitoring and Maintenance ​

Storage Usage Statistics ​

bash
sirrmeshd storage stats

Output:

Total Size: 125.5 GB
Users: 1,234
Average per User: 104.2 MB
Largest User: [email protected] (5.2 GB)

Cleanup Operations ​

Delete Expired Emails ​

bash
sirrmeshd cleanup --older-than 2y

Clean Trash ​

bash
sirrmeshd cleanup --trash --older-than 30d

Clean Temporary Files ​

bash
sirrmeshd cleanup --temp

Performance Optimization ​

Cache Configuration ​

toml
[storage.cache]
enabled = true
size_mb = 512
ttl = "1h"

Index Optimization ​

toml
[storage.indexing]
enabled = true
full_text_search = true

Concurrency Control ​

toml
[storage.concurrency]
max_workers = 10
queue_size = 1000

Data Security ​

Encryption ​

Transfer Encryption ​

toml
[storage.encryption]
# S3 transfer encryption
s3_use_tls = true

Encryption at Rest ​

toml
[storage.encryption]
enabled = true
algorithm = "AES-256-GCM"
key_file = "/etc/sirrmeshd/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 = true

Troubleshooting ​

Diagnostic Tools ​

bash
# Check storage connection
sirrmeshd storage test

# Verify data integrity
sirrmeshd storage verify

# Repair corrupted mailboxes
sirrmeshd storage repair --user [email protected]

Common Issues ​

Disk Space Insufficient ​

bash
# Clean old emails
sirrmeshd cleanup --older-than 1y

# Compress emails
sirrmeshd storage compress

S3 Connection Failed ​

bash
# Test S3 connection
sirrmeshd storage test --type s3

# View detailed errors
sirrmeshd storage test --debug

Related Documentation:

Released under the GPL 3.0 License.