# Restore backup
curl -X POST "http://localhost:7171/backup/restore/backup-20240101-120000"
```

### Automated Backup with CronJob

You can create a custom CronJob to automate the backup tool:

```yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: clickhouse-backup-tool-job
spec:
  schedule: "0 2 * * *" # Daily at 2 AM
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: backup-tool
              image: altinity/clickhouse-backup:2.6.23
              command:
                - /bin/bash
                - -c
                - |
                  BACKUP_NAME="backup-$(date +%Y%m%d-%H%M%S)"
                  curl -X POST "http://clickhouse-opik-clickhouse:7171/backup/create?name=$BACKUP_NAME"
                  sleep 30
                  curl -X POST "http://clickhouse-opik-clickhouse:7171/backup/upload/$BACKUP_NAME"
          restartPolicy: OnFailure
```

## Comparison

| Feature                 | SQL-based Backup | ClickHouse Backup Tool |
| ----------------------- | ---------------- | ---------------------- |
| **Setup Complexity**    | Simple           | Moderate               |
| **Compression**         | No               | Yes                    |
| **Incremental Backups** | No               | Yes                    |
| **Backup Validation**   | Basic            | Advanced               |
| **REST API**            | No               | Yes                    |
| **Restore Flexibility** | Basic            | Advanced               |
| **Resource Usage**      | Low              | Moderate               |
| **S3 Compatibility**    | Native           | Native                 |

## Best Practices

### General Recommendations

1. **Test Restores**: Regularly test backup restoration procedures
2. **Monitor Backup Jobs**: Set up monitoring for backup job failures
3. **Retention Policy**: Implement backup retention policies
4. **Cross-Region**: Consider cross-region backup replication for disaster recovery

### Security

1. **Access Control**: Use IAM roles when possible instead of access keys
2. **Encryption**: Enable S3 server-side encryption for backup storage
3. **Network Security**: Use VPC endpoints for S3 access when available

### Performance

1. **Schedule**: Run backups during low-traffic periods
2. **Resource Limits**: Set appropriate resource limits for backup jobs
3. **Storage Class**: Use appropriate S3 storage classes for cost optimization

## Troubleshooting

### Common Issues

#### Backup Job Fails

```bash