Back Up Arch Linux to Backblaze B2 with Restic

5/25/2025

Keeping your personal data safe is essential—especially on a rolling release distro like Arch Linux. In this post, I’ll walk through how I back up my /home directory using restic and Backblaze B2. We’ll cover a hybrid backup strategy, setting up credentials securely with environment variables, and automating the whole process using a shell script and cron.


🧭 Strategy Overview

1. Decide What to Back Up

Start by identifying which directories are important:

  • ~/Documents, ~/Pictures, project files, ~/.config, dotfiles
  • 🟡 Optional: media, ISO files, VM images
  • ❌ Skip: system files, applications—these can be reinstalled via pacman or restored with Timeshift

2. Choose a Backup Tool

Several good options support cloud backups on Linux:

ToolPros
ResticFast, secure, deduplicating, scriptable
DuplicatiGUI & CLI, encryption, supports B2, GDrive, S3
BorgBackupSnapshot-based, efficient, integrates with BorgBase
rcloneSync tool, not a backup solution, but flexible

In this post, we’ll use Restic for its simplicity and power.


3. Choose a Cloud Provider

Backblaze B2 is affordable, fast, and fully compatible with S3-based tools like Restic.

ProviderLinux-FriendlyBest ForNotes
Backblaze B2Low-cost offsite backupsWorks great with Restic

🛡️ Backup Strategy

Here's the hybrid setup I use:

MethodStorageFrequencyNotes
TimeshiftLocal SSDDailyRollback OS after system changes
rsync/ResticExternal SSDWeeklyFull backup of /home
Restic to B2CloudHourlySecure offsite backup of essentials

⚙️ Installing Restic and Initializing Backup

1. Install Restic

sudo pacman -S restic

2. Export Environment Variables

These are required for authentication with Backblaze B2:

export B2_ACCOUNT_ID="your_account_id"
export B2_ACCOUNT_KEY="your_app_key"
export RESTIC_PASSWORD="your_secure_password"

Or save these in a .env file and source them in your scripts:

# .env
B2_ACCOUNT_ID=your_account_id
B2_ACCOUNT_KEY=your_app_key
RESTIC_PASSWORD=your_secure_password

3. Initialize the Restic Repository

restic -r b2:your-bucket-name:/restic-repo init

For example:

restic -r b2:neil-t480s-backups:restic-t480s init

First Backup

restic -r b2:your-bucket:/restic-repo backup ~/Documents ~/Pictures

🔁 Automating Backups with a Script

Create a file at ~/restic-backup.sh:

#!/bin/bash

# Load environment variables
set -a
source /home/neil/.env
set +a

export RESTIC_REPOSITORY="b2:neil-t480s-backups:restic-t480s"

echo "Starting Restic backup: $(date)"

restic backup /home/neil \
  --exclude-caches \
  --exclude-if-present .nobackup \
  --exclude=/home/neil/Downloads \
  --exclude=/home/neil/.cache \
  --exclude=/home/neil/.npm \
  --exclude=/home/neil/.nvm \
  --exclude=/home/neil/.pyenv \
  --exclude=/home/neil/.var \
  --exclude=/home/neil/.mozilla \
  --exclude=/home/neil/snap \
  --exclude=/home/neil/Public \
  --exclude=/home/neil/Projects/1password \
  --exclude=/home/neil/Templates \
  --exclude=/home/timeshift \
  >> /home/neil/Projects/restic/restic-backup.log 2>&1

restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune

echo "Finished Restic backup: $(date)"

Make it executable:

chmod +x ~/restic-backup.sh

🕒 Running It with Cron

Edit your crontab:

crontab -e

Add this line to run every hour:

0 * * * * /home/neil/restic-backup.sh >> /home/neil/restic-backup.log 2>&1

🧠 Pro Tips

• Encrypt everything: Restic uses AES-256 encryption by default. • Automate: Use cron or systemd timers. • Prune regularly: Prevents your storage from bloating. • Verify restores: Test with restic restore or restic mount.

🔄 Next Steps

Want help setting up restic restore or browsing your backup using restic mount? I’ll cover that in a follow-up post.


This post is part of my ongoing Arch Linux homelab series. Soon you may find related content and setup guides at neilpatterson.dev.