What Is Restic?
Restic is a fast, secure backup program that supports multiple storage backends including local disk, SFTP, AWS S3, Backblaze B2, and Google Cloud Storage. All data is encrypted by default.
Installation
sudo apt install -y restic
# Or get the latest version
wget https://github.com/restic/restic/releases/download/v0.16.3/restic_0.16.3_linux_amd64.bz2
bunzip2 restic_*.bz2 && chmod +x restic_* && sudo mv restic_* /usr/local/bin/resticInitialize a Repository
# Local
restic init --repo /backups/restic-repo
# SFTP
restic init --repo sftp:user@backup-server:/backups/restic
# S3
export AWS_ACCESS_KEY_ID=your-key
export AWS_SECRET_ACCESS_KEY=your-secret
restic init --repo s3:s3.amazonaws.com/mybucket/restic
# Backblaze B2
export B2_ACCOUNT_ID=your-id
export B2_ACCOUNT_KEY=your-key
restic init --repo b2:mybucket:resticCreate a Backup
# Backup directories
restic -r /backups/restic-repo backup /var/www /etc /home
# With exclusions
restic -r /backups/restic-repo backup /var/www --exclude="*.log" --exclude="node_modules"List and Restore Snapshots
# List all snapshots
restic -r /backups/restic-repo snapshots
# Restore latest snapshot
restic -r /backups/restic-repo restore latest --target /tmp/restore
# Restore specific files
restic -r /backups/restic-repo restore latest --target /tmp/restore --include "/var/www"Automated Backup Script
#!/bin/bash
export RESTIC_REPOSITORY="/backups/restic-repo"
export RESTIC_PASSWORD="your-secure-password"
restic backup /var/www /etc /home --exclude="*.log"
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
restic checkKey Features
- Deduplication — only stores unique data chunks
- Encryption — AES-256 encryption for all data
- Cross-platform — works on Linux, macOS, Windows
- Fast — incremental backups complete quickly