Add comprehensive backup and restore infrastructure
- scripts/borg-backup.sh: Complete disaster recovery backup (PostgreSQL, Docker volumes, configs, SSL certs, DKIM keys) - scripts/borg-restore.sh: Automated restore from Borg backups with manual verification steps - scripts/rollback.sh: Quick application rollback using Docker image tags - Enhanced setup.sh with BorgBackup installation and cron job setup - Updated README with detailed backup strategy documentation (2-tier: SQLite + Borg) Backup retention: 7 daily + 4 weekly + 3 monthly Borg archives + 7 days SQLite snapshots
This commit is contained in:
parent
3820d7ea4d
commit
76c1cc3bfb
4 changed files with 384 additions and 6 deletions
|
|
@ -137,12 +137,63 @@ docker-compose up -d
|
|||
|
||||
### Backup System
|
||||
```bash
|
||||
mkdir -p /opt/docfast-backups
|
||||
# Install BorgBackup
|
||||
apt install -y borgbackup
|
||||
|
||||
# Create backup directories
|
||||
mkdir -p /opt/docfast-backups /opt/borg-backups
|
||||
|
||||
# Copy backup scripts
|
||||
cp scripts/docfast-backup.sh /opt/
|
||||
chmod +x /opt/docfast-backup.sh
|
||||
cp scripts/borg-backup.sh /opt/
|
||||
cp scripts/borg-restore.sh /opt/
|
||||
cp scripts/rollback.sh /opt/
|
||||
chmod +x /opt/docfast-backup.sh /opt/borg-backup.sh /opt/borg-restore.sh /opt/rollback.sh
|
||||
|
||||
# Add to root crontab
|
||||
echo "0 */6 * * * /opt/docfast-backup.sh >> /var/log/docfast-backup.log 2>&1" | crontab -
|
||||
echo "0 3 * * * /opt/borg-backup.sh >> /var/log/borg-backup.log 2>&1" | crontab -
|
||||
```
|
||||
|
||||
## Backup Strategy
|
||||
|
||||
DocFast uses a two-tier backup strategy for comprehensive data protection:
|
||||
|
||||
### 1. SQLite Database Backups (Every 6 hours)
|
||||
- **Script**: `/opt/docfast-backup.sh`
|
||||
- **Frequency**: Every 6 hours via cron
|
||||
- **Retention**: 7 days of backups (28 files), plus 4 weekly copies
|
||||
- **Storage**: `/opt/docfast-backups/`
|
||||
- **Method**: SQLite `.backup` command with integrity verification
|
||||
|
||||
### 2. Complete System Backups (Daily)
|
||||
- **Script**: `/opt/borg-backup.sh`
|
||||
- **Frequency**: Daily at 03:00 UTC via cron
|
||||
- **Retention**: 7 daily + 4 weekly + 3 monthly
|
||||
- **Storage**: `/opt/borg-backups/docfast`
|
||||
- **Includes**:
|
||||
- PostgreSQL database dump
|
||||
- Docker volumes (complete application data)
|
||||
- Nginx configuration
|
||||
- SSL certificates (Let's Encrypt)
|
||||
- OpenDKIM keys and configuration
|
||||
- Cron jobs and system configurations
|
||||
- Application files (.env, docker-compose.yml)
|
||||
- System information (packages, services)
|
||||
|
||||
### Backup Management Commands
|
||||
```bash
|
||||
# List available Borg backups
|
||||
/opt/borg-restore.sh list
|
||||
|
||||
# Restore from latest backup (creates restore directory)
|
||||
/opt/borg-restore.sh restore latest
|
||||
|
||||
# Restore from specific backup
|
||||
/opt/borg-restore.sh restore docfast-2026-02-15_0300
|
||||
|
||||
# Quick rollback (Docker image only)
|
||||
/opt/rollback.sh
|
||||
```
|
||||
|
||||
## Disaster Recovery Procedures
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue