Home ServersTechnician

Encrypted Backup Server with BorgBackup

Deduplicated, encrypted nightly backups of your computers and Pi projects to a drive you control.

LevelTechnician
Time1 h
Est. cost~$149
Steps5

BorgBackup stores only the changes between backups and encrypts everything before it leaves your computer. A Pi with a USB drive makes a quiet backup target; copy it off-site for real protection.

⚠ SAFETY
Lose the passphrase and key and the backups are gone forever. Store them in your password manager and on paper.

Mission steps

  1. Prepare the drive

    Mount the USB drive at /mnt/backup and create a dedicated user for backups.

  2. Install Borg on both sides

    sudo apt install borgbackup on the Pi and install Borg (or the Vorta app) on your computer.

  3. Create an encrypted repository

    borg init --encryption=repokey over SSH. Export and store the key somewhere safe.

  4. Back up on a schedule

    Run borg create nightly with a cron job or Vorta's scheduler, and prune old archives.

  5. Test a restore

    A backup you have never restored is not a backup. Mount an archive and copy a file back.

Code

# from your computer
borg init --encryption=repokey ssh://backup@mc-pi.local/mnt/backup/laptop
borg create --stats ssh://backup@mc-pi.local/mnt/backup/laptop::'{hostname}-{now}' ~/Documents ~/Projects
borg prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6 ssh://backup@mc-pi.local/mnt/backup/laptop

Tip: test every script on the bench before installing it in a moving machine.

Questions

What is the 3-2-1 rule?

3 copies of your data, on 2 different media, with 1 copy off-site.