Get a Pentest and security assessment of your IT network.

Cyber Security

Email Backup on VPS: Privacy & Security

TL;DR

Backing up your email to a Virtual Private Server (VPS) gives you control, but requires careful setup for privacy and security. This guide covers choosing the right tools, securing your server, and automating backups.

1. Choose Your Backup Method

There are several ways to back up your email. Here are a few common options:

  • IMAP Sync: Most email clients (Thunderbird, Outlook) can sync emails with an IMAP server. You’ll need an IMAP account on your VPS. This is simple but relies heavily on the security of that account.
  • Mbox Export/Import: Many email clients allow exporting to Mbox format. You can then copy this file to your VPS. Good for archiving, less ideal for regular backups.
  • Dedicated Backup Tools (e.g., Rclone): These tools offer more flexibility and control over the backup process, including encryption and scheduling.

We’ll focus on IMAP sync as it’s relatively easy to set up.

2. Set Up Your VPS

  1. Choose a Provider: Select a reputable VPS provider (DigitalOcean, Linode, Vultr). Consider their privacy policies and data centre locations.
  2. Operating System: Ubuntu Server is a good choice for beginners.
  3. SSH Access: Securely connect to your server using SSH. Always use strong passwords or SSH keys.

3. Install and Configure an IMAP Server

We’ll use Dovecot, a popular IMAP/POP3 server.

  1. Update Package Lists:
    sudo apt update
  2. Install Dovecot:
    sudo apt install dovecot-imapd dovecot-pop3d dovecot-core
  3. Configure Dovecot: Edit /etc/dovecot/conf.d/10-mail.conf and set the mail location (e.g., to a directory under your user’s home folder).
  4. Create User Account: Create a dedicated user account for email backups.
    sudo adduser backupuser
  5. Restart Dovecot:
    sudo systemctl restart dovecot

4. Secure Your IMAP Server

Security is paramount! These steps are crucial.

  1. Firewall (UFW): Enable a firewall and only allow SSH, IMAP/POP3 traffic.
    sudo ufw enable

    sudo ufw allow ssh

    sudo ufw allow 993/tcp  # IMAPS (secure)

    sudo ufw allow 143/tcp # IMAP (insecure - avoid if possible)
  2. SSL/TLS Certificate: Use Let’s Encrypt to obtain a free SSL/TLS certificate. This encrypts the connection between your email client and server.
    Install Certbot:
    sudo apt install certbot python3-certbot-nginx

    Run Certbot (assuming you have Nginx installed):

    sudo certbot --nginx -d yourdomain.com -d mail.yourdomain.com
  3. Strong Passwords: Use strong, unique passwords for all accounts. Consider using a password manager.
  4. Regular Updates: Keep your server software up to date with security patches.
    sudo apt update && sudo apt upgrade

5. Configure Your Email Client

Add an IMAP account in your email client, using the VPS’s hostname/IP address and the credentials you created.

6. Automate Backups

Regular backups are essential. Use a tool like cron to schedule them.

  1. Create Backup Script: Write a script that copies your email data (e.g., the mail directory) to another location on the VPS or an external storage device.
  2. Edit Crontab:
    crontab -e

    Add a line like this to run the script daily at 2 AM:

    0 2 * * * /path/to/your/backup_script.sh

7. Consider Offsite Backups

Store backups in multiple locations to protect against server failure or compromise.

  • Rclone: Use Rclone to sync your backups to cloud storage (Backblaze B2, Amazon S3).
  • External Hard Drive: Periodically copy backups to an external hard drive.

8. Privacy Considerations

  • Encryption: Encrypt your email data at rest on the VPS using tools like GPG or LUKS.
  • Data Location: Be aware of where your VPS provider stores your data and their privacy policies.
  • Access Control: Limit access to your backups as much as possible.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation