Restic is a modern backup tool with built-in encryption, deduplication and compression. It supports multiple backends and is significantly faster than traditional tools.
Step 1 — Install Restic
sudo apt install restic -y
Step 2 — Initialize Repository
# Local
restic init --repo /backups/myrepo
# 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:restic
Step 3 — Create Backup
export RESTIC_REPOSITORY=/backups/myrepo
export RESTIC_PASSWORD=your-strong-password
restic backup /var/www --exclude='*.log'
Step 4 — Backup MySQL
mysqldump --all-databases -u root -p'password' | restic backup --stdin --stdin-filename all-databases.sql
Step 5 — Schedule
0 2 * * * RESTIC_PASSWORD=password restic backup /var/www && restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
Step 6 — Restore
restic snapshots
restic restore latest --target /restore/
Conclusion
Restic provides enterprise-grade backup features for free. Our team configures automated backup solutions using Restic.
Comments