# Email Backup Daily incremental backup of all email accounts to atlantis NAS. ## Overview | Property | Value | |----------|-------| | **Script** | `scripts/gmail-backup-daily.sh` → `scripts/gmail-backup.py` | | **Schedule** | Daily at 3:00 AM (cron on homelab-vm) | | **Destination** | `/mnt/atlantis_archive/old_emails/` (NFS → atlantis `/volume1/archive/old_emails/`) | | **Local copy** | `/tmp/gmail_backup` (non-persistent, fast access) | | **Log** | `/tmp/gmail-backup-daily.log` | | **Format** | `.eml` files organized by account → folder | ## Accounts | Account | Protocol | Host | Directory | |---------|----------|------|-----------| | your-email@example.com | IMAP SSL | imap.gmail.com:993 | `dvish92/` | | lzbellina92@gmail.com | IMAP SSL | imap.gmail.com:993 | `lzbellina92/` | | admin@thevish.io | IMAP STARTTLS | 127.0.0.1:1143 (Proton Bridge) | `proton_admin/` | ## Behavior - **Incremental**: Only downloads emails not already on disk (checks by filename) - **Never deletes**: Emails removed from the source stay in the backup - **Auto-reconnects**: Gmail throttles IMAP connections; the script reconnects and continues on disconnect - **Proton Bridge required**: admin@thevish.io backup needs Proton Bridge running on homelab-vm (`tmux new-session -d -s bridge '/usr/lib/protonmail/bridge/bridge --cli'`) - **Fault tolerant**: If Proton Bridge is down, Gmail accounts still back up. If NFS is unmounted, falls back to local-only backup. ## Infrastructure ### NFS Mount ``` 192.168.0.200:/volume1/archive → /mnt/atlantis_archive (NFSv3, sec=sys) ``` Persisted in `/etc/fstab`. Requires `lan-route-fix.service` to be active (routes LAN traffic via ens18 instead of Tailscale). ### Cron ```cron 0 3 * * * /home/homelab/organized/repos/homelab/scripts/gmail-backup-daily.sh >> /tmp/gmail-backup-daily.log 2>&1 ``` ## Manual Operations ```bash # Run backup manually /home/homelab/organized/repos/homelab/scripts/gmail-backup-daily.sh # Run for a specific destination python3 scripts/gmail-backup.py /path/to/output # Check backup status find /mnt/atlantis_archive/old_emails -name "*.eml" | wc -l # Check log tail -20 /tmp/gmail-backup-daily.log # Verify mount mountpoint -q /mnt/atlantis_archive && echo "mounted" || echo "NOT mounted" ``` ## Troubleshooting | Issue | Fix | |-------|-----| | `PermissionError` on NFS | `ssh atlantis "chmod -R a+rwX /volume1/archive/old_emails/"` | | NFS mount fails | Check `lan-route-fix.service` is active: `sudo systemctl start lan-route-fix` | | Proton account fails | Verify bridge: `tmux attach -t bridge`. Restart if needed. | | Gmail IMAP disconnects | Normal — Gmail rate-limits. Script auto-reconnects. | | `socket error: EOF` in log | IMAP throttling. Script handles this automatically. |