How to Set Up Automated Linux Backups with Restic
Affiliate Disclosure: This article contains affiliate links.
Restic is a modern backup solution that's fast, secure, and deduplicated. In this guide, you'll learn to set up automated, encrypted backups for your Linux servers.
What is Restic?
Restic is an open-source backup tool that offers:
- Client-side encryption before data leaves your server
- Deduplication across backup snapshots
- Multiple storage backends (local, S3, Backblaze, etc.)
Prerequisites
- Linux server (Ubuntu 20.04+, CentOS 8+, or similar)
- sudo/root access
- Backup storage destination
Step 1: Install Restic
sudo apt update
sudo apt install restic
Step 2: Initialize Repository
export RESTIC_REPOSITORY=/backup/my-backups
export RESTIC_PASSWORD_FILE=~/.restic-password
echo "YourSuperSecurePasswordHere" > ~/.restic-password
chmod 600 ~/.restic-password
restic init
Step 3: Create Your First Backup
restic backup /var/www/html /etc/nginx \
--tag "web" \
--tag "production"
Step 4: Automation with Cron
sudo crontab -e
0 2 * * * /usr/local/bin/restic-backup.sh
Best Practices
- Store password file with 600 permissions
- Use separate backup user account
- Test restore procedures regularly
Frequently Asked Questions
How long does a typical backup take?
For 10GB of data: Local storage takes 2-5 minutes, S3 takes 5-15 minutes depending on bandwidth.
How secure are the backups?
Restic uses AES-256 encryption with a key derived from your password using scrypt.