Skip to main content

Restic Deduplicated Backup Guide

Overview

Restic provides encrypted, deduplicated backups with advanced features like integrity checking, efficient storage, and snapshot management.

Key Features

  • Deduplication: Only stores changed data blocks
  • Encryption: AES-256 encryption at rest
  • Compression: Automatic data compression
  • Verification: Built-in integrity checking
  • Snapshots: Point-in-time recovery
  • Incremental: Fast incremental backups

Backup Types

Full Backup with Verification

  • Schedule: Daily at 4:00 AM
  • Method: Complete snapshot + integrity check + prune
  • Location: onedrive-donnyaw:16.Docker-Backup/Docusaurus/Restic-Rclone/
  • Script: /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/full-backup.sh

Incremental Backup

  • Schedule: Daily at 5:00 AM
  • Method: Fast deduplicated snapshot
  • Location: Same repository (deduplicated)
  • Script: /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/incremental-backup.sh

Repository Information

Repository Location

RESTIC_REPOSITORY="rclone:onedrive-donnyaw:16.Docker-Backup/Docusaurus/Restic-Rclone"

Repository Password

# Stored in backup-config.sh
RESTIC_PASSWORD="DocusaurusSecureBackup2026!"
Important

Keep this password safe! Without it, you cannot access your backups. Store it in a secure password manager.

Configuration

Source Directory

BACKUP_SOURCE="/opt/docker-data/apps/docusaurus/site"

Retention Policy

KEEP_DAILY=7 # Keep 7 daily backups
KEEP_WEEKLY=4 # Keep 4 weekly backups
KEEP_MONTHLY=6 # Keep 6 monthly backups
KEEP_YEARLY=1 # Keep 1 yearly backup

Manual Backup Operations

Run Full Backup

cd /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/
./full-backup.sh

Run Incremental Backup

cd /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/
./incremental-backup.sh

List All Snapshots

# Source configuration
source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh

# List snapshots
restic snapshots

View Specific Snapshot

# Get snapshot ID from list
restic snapshots

# View snapshot details
restic snapshots <snapshot-id>

# List files in snapshot
restic ls <snapshot-id>

Restore Procedures

Method 1: Using Restore Script

1. List Available Snapshots

cd /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/
./restore-backup.sh list

2. Restore Latest Snapshot

# Restore to temporary location
./restore-backup.sh latest /tmp/docusaurus-restore

3. Restore Specific Snapshot

# Use snapshot ID from list
./restore-backup.sh <snapshot-id> /tmp/docusaurus-restore

Method 2: Manual Restore with Restic

1. Set Environment Variables

# Source configuration
source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh

# Verify connection
restic snapshots

2. List Snapshots

# List all snapshots
restic snapshots

# List snapshots with specific tag
restic snapshots --tag docusaurus

# Find latest snapshot
restic snapshots --last 1

3. Restore Snapshot

# Restore latest snapshot
restic restore latest --target /tmp/docusaurus-restore

# Restore specific snapshot
restic restore <snapshot-id> --target /tmp/docusaurus-restore

# Restore specific path only
restic restore latest --target /tmp/docusaurus-restore --path /docs

# Restore with include pattern
restic restore latest --target /tmp/docusaurus-restore --include "*.md"

Method 3: Restore to Live Server

Complete Restore Process

# 1. Stop Docusaurus container
cd /opt/docker-data/apps/docusaurus
docker-compose down

# 2. Backup current site (safety)
mv site site.backup.$(date +%Y%m%d_%H%M%S)

# 3. Source restic configuration
source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh

# 4. Restore from latest snapshot
mkdir -p /tmp/docusaurus-restore
restic restore latest --target /tmp/docusaurus-restore

# 5. Move restored files to site directory
mv /tmp/docusaurus-restore site

# 6. Set correct permissions
chown -R rezriz:rezriz site/

# 7. Restart container
docker-compose up -d

# 8. Verify site is working
docker-compose logs -f

# 9. Test site in browser
# Visit: https://brain.id86.net

Unlocking a Locked Repository

If a backup process crashes, the repository may remain locked.

Check for Locks

source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh
restic list locks

Remove Stale Locks

# Remove all locks (use with caution)
restic unlock

# Or remove specific lock
restic unlock --remove-all
Caution

Only remove locks if you're certain no backup process is running. Removing locks while a backup is active can corrupt the repository.

Verify Lock Removal

# Check locks again
restic list locks

# Should return empty if successful

Advanced Operations

Check Repository Integrity

source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh

# Quick check
restic check

# Deep check (reads all data)
restic check --read-data

# Check specific percentage
restic check --read-data-subset=10%

View Repository Statistics

# Overall stats
restic stats

# Stats for specific snapshot
restic stats <snapshot-id>

# Raw data size
restic stats --mode raw-data

# Restore size
restic stats --mode restore-size

Prune Old Snapshots

# Forget old snapshots (doesn't free space yet)
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --keep-yearly 1

# Prune to actually free space
restic prune

# Combined forget and prune
restic forget --keep-daily 7 --keep-weekly 4 --prune

Mount Repository as Filesystem

# Create mount point
mkdir -p /tmp/restic-mount

# Mount repository
restic mount /tmp/restic-mount

# Browse in another terminal
ls -la /tmp/restic-mount/snapshots/

# Unmount when done
fusermount -u /tmp/restic-mount

Restore Specific Files

Find File in Snapshots

# Search for file across all snapshots
restic find "filename.md"

# Search in specific path
restic find --path /docs "*.mdx"

Restore Single File

# Restore specific file from latest snapshot
restic restore latest --target /tmp/restore --include "docs/specific-file.md"

# Copy to live location
cp /tmp/restore/docs/specific-file.md /opt/docker-data/apps/docusaurus/site/docs/

Logs and Monitoring

View Backup Logs

# Full backup logs
tail -f /home/rezriz/logs/restic-backups/docusaurus-backup-$(date +%Y%m%d).log

# Cron logs
tail -f /home/rezriz/logs/restic-backups/docusaurus-full-cron.log
tail -f /home/rezriz/logs/restic-backups/docusaurus-incremental-cron.log

Check Last Backup Status

source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh

# View latest snapshot
restic snapshots --last 1

# Check when last backup ran
ls -lht /home/rezriz/logs/restic-backups/ | head

Troubleshooting

Repository Not Found

# Initialize repository
source /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh
restic init

Wrong Password

# Verify password in config
cat /home/rezriz/github/01-production/vps-management/backup-scripts/docusaurus-restic-rclone/backup-config.sh | grep RESTIC_PASSWORD

# Set password manually
export RESTIC_PASSWORD="DocusaurusSecureBackup2026!"

Rclone Connection Issues

# Test rclone connection
rclone lsd onedrive-donnyaw:

# Test specific path
rclone lsd onedrive-donnyaw:16.Docker-Backup/Docusaurus/Restic-Rclone/

Backup Running Slow

# Check network speed
rclone test speed onedrive-donnyaw:

# Use local cache
export RESTIC_CACHE_DIR=/tmp/restic-cache

Repository Corruption

# Check repository
restic check --read-data

# Rebuild index
restic rebuild-index

# If severely corrupted, restore from last known good backup

Disaster Recovery

Complete Site Recovery Steps

  1. Prepare New Server

    # Install dependencies
    sudo apt-get update
    sudo apt-get install -y restic rclone docker.io docker-compose
  2. Configure Rclone

    # Copy rclone config or reconfigure
    rclone config
  3. Set Restic Password

    export RESTIC_PASSWORD="DocusaurusSecureBackup2026!"
    export RESTIC_REPOSITORY="rclone:onedrive-donnyaw:16.Docker-Backup/Docusaurus/Restic-Rclone"
  4. Restore Latest Snapshot

    mkdir -p /opt/docker-data/apps/docusaurus/site
    restic restore latest --target /opt/docker-data/apps/docusaurus/site
  5. Set Up Docker

    cd /opt/docker-data/apps/docusaurus
    # Copy docker-compose.yml from backup or repository
    docker-compose up -d
  6. Verify Recovery

    docker-compose logs -f
    # Test site access

Best Practices

  1. Regular Testing - Test restore procedures monthly
  2. Monitor Logs - Check backup logs for errors
  3. Verify Integrity - Run restic check weekly
  4. Keep Password Safe - Store in password manager
  5. Document Changes - Update docs when changing configuration
  6. Multiple Backup Methods - Use both Rclone and Restic
  7. Off-site Storage - OneDrive provides geographic redundancy
  8. Retention Policy - Balance storage cost vs. recovery needs

Security Considerations

  1. Encryption - All data encrypted with AES-256
  2. Password Protection - Repository password required for access
  3. Access Control - Limit who can access backup scripts
  4. Audit Logs - Review backup logs regularly
  5. Secure Transfer - Rclone uses HTTPS for OneDrive

Performance Tips

  1. Use Local Cache - Speeds up operations
  2. Limit Bandwidth - Use --limit-upload and --limit-download
  3. Parallel Uploads - Rclone automatically parallelizes
  4. Exclude Unnecessary Files - Reduce backup size
  5. Schedule Off-Peak - Run backups during low-traffic hours