Skip to content

Restic Backups with S3 Storage

Overview

Professional Backup Solution

Restic is a modern backup program that provides fast, secure, and efficient backups to S3 storage. Perfect for backing up your Mac, Linux, or Windows systems to Euronodes S3 storage.

Why Restic?

Restic Advantages

  • Deduplication - Only stores unique data blocks, saving space
  • Encryption - All data is encrypted before leaving your system
  • Cross-Platform - Works on Mac, Linux, and Windows
  • Incremental - Only backs up changed data after initial backup
  • Verification - Built-in integrity checking and verification
  • S3 Compatible - Works perfectly with Euronodes S3 storage

Installation

Mac Installation

Install via Homebrew

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Restic
brew install restic

# Verify installation
restic version

Linux Installation

Linux Installation Options

# Ubuntu/Debian
sudo apt update
sudo apt install restic

# CentOS/RHEL/Fedora
sudo dnf install restic

# Or download binary
wget https://github.com/restic/restic/releases/latest/download/restic_linux_amd64.bz2
bunzip2 restic_linux_amd64.bz2
chmod +x restic_linux_amd64
sudo mv restic_linux_amd64 /usr/local/bin/restic

Windows Installation

Windows Setup

  1. Download from restic.net
  2. Extract to a folder (e.g., C:\restic\)
  3. Add to PATH environment variable
  4. Open Command Prompt and verify: restic version

Mac Backup Setup

Prerequisites

Before You Start

  • Ensure you have S3 credentials configured
  • Choose a strong password for your backup repository
  • Identify which directories you want to backup

Complete Mac Backup Script

Production-Ready Backup Script

Create a file called restic_s3.sh:

#!/bin/bash

# S3 Configuration
export AWS_ACCESS_KEY_ID=<ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
export RESTIC_REPOSITORY=s3:https://eu-west-1.euronodes.com/mac-backup
export RESTIC_PASSWORD="YourSecurePassword"

# Initialize repository (run once)
# restic init

# Backup important directories
restic backup \
    --exclude-caches \
    --exclude .DS_Store \
    --exclude "*/Library/Caches/*" \
    --exclude "*/node_modules/*" \
    --exclude "*/target/*" \
    --exclude "*/.git/*" \
    --exclude "*/build/*" \
    --exclude "*/.venv/*" \
    --exclude "*/venv/*" \
    ~/Documents \
    ~/Desktop \
    ~/.local \
    ~/Projects

# Keep last 7 daily, 4 weekly, 12 monthly backups
restic forget --prune --keep-daily 7 --keep-weekly 4 --keep-monthly 12

echo "Backup completed successfully!"

Script Configuration

Setup Instructions

  1. Replace Credentials - Update <ACCESS_KEY> and <SECRET_KEY> with your actual S3 credentials
  2. Set Repository Name - Change mac-backup to your preferred bucket name
  3. Choose Strong Password - Replace YourSecurePassword with a secure password
  4. Customize Paths - Modify the backup paths to match your needs

Security Setup

Secure Your Script

# Make script executable and secure
chmod 700 restic_s3.sh

# Move to a secure location
mkdir -p ~/.local/bin
mv restic_s3.sh ~/.local/bin/

# Add to PATH if needed
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

First-Time Setup

Initialize Repository

# Make script executable
chmod +x ~/.local/bin/restic_s3.sh

# Edit script to uncomment the init line
nano ~/.local/bin/restic_s3.sh
# Uncomment: restic init

# Run initialization
~/.local/bin/restic_s3.sh

# Comment out the init line after first run
nano ~/.local/bin/restic_s3.sh
# Comment: # restic init

Advanced Backup Configurations

Multiple Backup Sets

Organize Different Backups

Create separate scripts for different backup types:

Documents Backup

#!/bin/bash
export AWS_ACCESS_KEY_ID=<ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
export RESTIC_REPOSITORY=s3:https://eu-west-1.euronodes.com/documents-backup
export RESTIC_PASSWORD="DocumentsPassword"

restic backup \
    --exclude .DS_Store \
    ~/Documents \
    ~/Desktop

Development Projects Backup

#!/bin/bash
export AWS_ACCESS_KEY_ID=<ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
export RESTIC_REPOSITORY=s3:https://eu-west-1.euronodes.com/projects-backup
export RESTIC_PASSWORD="ProjectsPassword"

restic backup \
    --exclude "*/node_modules/*" \
    --exclude "*/target/*" \
    --exclude "*/.git/*" \
    --exclude "*/build/*" \
    ~/Projects \
    ~/Development

Automated Scheduling

Schedule Regular Backups

Using Cron (Mac/Linux)

# Edit crontab
crontab -e

# Add daily backup at 2 AM
0 2 * * * /Users/yourusername/.local/bin/restic_s3.sh >> /var/log/restic-backup.log 2>&1

# Add weekly full backup on Sundays at 3 AM
0 3 * * 0 /Users/yourusername/.local/bin/restic_s3.sh >> /var/log/restic-backup.log 2>&1

Using launchd (Mac)

Create ~/Library/LaunchAgents/com.restic.backup.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.restic.backup</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/yourusername/.local/bin/restic_s3.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>2</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>

Load the service:

launchctl load ~/Library/LaunchAgents/com.restic.backup.plist

Backup Management

Monitoring Backups

Check Backup Status

# Set environment variables
export RESTIC_REPOSITORY=s3:https://eu-west-1.euronodes.com/mac-backup
export RESTIC_PASSWORD="YourSecurePassword"

# List all snapshots
restic snapshots

# Check repository integrity
restic check

# Show repository statistics
restic stats

# List files in latest snapshot
restic ls latest

Backup Verification

Verify Backup Integrity

# Quick check
restic check

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

# Check subset of data (faster)
restic check --read-data-subset=10%

Cleanup and Maintenance

Manage Storage Space

# Remove old snapshots (keep policy)
restic forget --prune --keep-daily 7 --keep-weekly 4 --keep-monthly 12

# Remove specific snapshot
restic forget <snapshot-id> --prune

# Rebuild index (if needed)
restic rebuild-index

# Optimize repository
restic prune

Restore Operations

Restore Files

Restore Your Data

# Restore latest snapshot to specific directory
restic restore latest --target ~/restored-files

# Restore specific files/directories
restic restore latest --target ~/restored-files --include "*/Documents/*"

# Restore from specific snapshot
restic restore <snapshot-id> --target ~/restored-files

# Restore with original paths
restic restore latest --target /

Browse Backups

Explore Backup Contents

# Mount backup as filesystem (Mac/Linux)
mkdir ~/backup-mount
restic mount ~/backup-mount

# Browse in Finder/file manager
open ~/backup-mount

# Unmount when done
umount ~/backup-mount

Selective Restore

Restore Specific Items

# Find files
restic find "*.pdf"
restic find "important-document.txt"

# Restore found files
restic restore latest --target ~/restored --include "*important-document.txt"

# Restore by date
restic snapshots --json | jq '.[] | select(.time | startswith("2024-01"))'

Performance Optimization

Speed Improvements

Optimize Backup Performance

# Use multiple connections
restic backup --option s3.connections=10 ~/Documents

# Limit bandwidth (KB/s)
restic backup --limit-upload 1000 ~/Documents

# Exclude cache directories
restic backup --exclude-caches ~/Documents

# Use compression
restic backup --compression max ~/Documents

Large File Handling

Handle Large Files Efficiently

# Backup large files separately
restic backup --exclude "*.iso" --exclude "*.dmg" ~/Documents

# Backup large files with different retention
restic backup ~/LargeFiles
restic forget --keep-daily 3 --keep-weekly 2 --prune

Troubleshooting

Common Issues

Solving Problems

Connection Issues

# Test S3 connectivity
aws s3 ls --endpoint-url https://eu-west-1.euronodes.com

# Verify credentials
export AWS_ACCESS_KEY_ID=<ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
aws sts get-caller-identity --endpoint-url https://eu-west-1.euronodes.com

Repository Issues

# Check repository
restic check

# Repair repository
restic repair index
restic repair snapshots

# Unlock repository (if locked)
restic unlock

Performance Issues

# Check repository stats
restic stats

# Optimize repository
restic prune

# Rebuild index
restic rebuild-index

FAQ

How much space will my backups use?

Restic uses deduplication, so initial backup is full size, but subsequent backups only store changed data. Typically 10-30% of original data size for regular backups.

Can I backup to multiple destinations?

Yes, you can create multiple scripts with different repositories for redundancy.

What happens if I forget my restic password?

The password cannot be recovered. Your backups will be permanently inaccessible. Store your password securely.

Can I backup while using my computer?

Yes, restic can backup files while they're in use, though some files may be skipped if locked.

How do I migrate to a new computer?

Install restic, configure with same credentials and password, then restore your files to the new system.

Contact Support

Need Help?

  • Backup Issues: Open support ticket through client portal
  • S3 Configuration: Include repository name and error messages
  • Performance Problems: Specify backup size and current performance metrics

For S3 setup instructions, see S3 Configuration