> ## Documentation Index
> Fetch the complete documentation index at: https://developer.verilock.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Backup & Restore

> Backup strategies for your self-hosted Verilock Identity deployment

## What to Back Up

| Component           | Contains                                                      | Priority |
| ------------------- | ------------------------------------------------------------- | -------- |
| **PostgreSQL**      | All verification data, sessions, AML results, users, settings | Critical |
| **MinIO / Storage** | KYC documents, selfies, ID photos, address proofs             | Critical |
| **`.env` file**     | Configuration, license key, passwords                         | Critical |
| **Redis**           | Cache and queue state (ephemeral)                             | Low      |

## Database Backup

### Manual Backup

```bash theme={null}
docker compose exec postgres pg_dump -U verilock verilock > backup-$(date +%Y%m%d-%H%M%S).sql
```

### Compressed Backup

```bash theme={null}
docker compose exec postgres pg_dump -U verilock verilock | gzip > backup-$(date +%Y%m%d).sql.gz
```

### Automated Daily Backup

Create a cron job on the host:

```bash theme={null}
crontab -e
```

Add:

```
0 2 * * * cd /path/to/verilock && docker compose exec -T postgres pg_dump -U verilock verilock | gzip > /backups/verilock-$(date +\%Y\%m\%d).sql.gz
```

## Document Storage Backup

### MinIO to Local

```bash theme={null}
# Install mc (MinIO client) on host
docker compose exec minio mc mirror local/verilock-documents /tmp/backup-documents

# Copy from container
docker compose cp minio:/tmp/backup-documents ./backup-documents
```

### MinIO to S3

```bash theme={null}
docker compose exec minio mc alias set aws https://s3.amazonaws.com YOUR_KEY YOUR_SECRET
docker compose exec minio mc mirror local/verilock-documents aws/your-backup-bucket/verilock/
```

## Restore

### Database

```bash theme={null}
# Stop the app (prevent writes during restore)
docker compose stop app

# Restore
cat backup-20260317.sql | docker compose exec -T postgres psql -U verilock -d verilock

# Or from gzip
gunzip -c backup-20260317.sql.gz | docker compose exec -T postgres psql -U verilock -d verilock

# Restart
docker compose start app
```

### Documents

```bash theme={null}
docker compose cp ./backup-documents minio:/data/verilock-documents
docker compose restart minio
```

## Disaster Recovery

For full disaster recovery, maintain offsite copies of:

1. **Database dump** (daily)
2. **Document storage** (daily or real-time sync)
3. **`.env` file** (after any config change)
4. **`docker-compose.yml`** (after any modification)

<Tip>
  Store backups in a different location than your deployment. Use encrypted storage for backups containing PII.
</Tip>
