# Restic + REST Server + Prometheus

> Fast and secure backup program with REST server.

- Category: Storage & Backup
- Difficulty: intermediate
- Components: restic-rest-server, prometheus, grafana
- Tags: restic, backup, encryption, deduplication, rest-server
- Source: https://docker.recipes/storage/restic-backup-server

## Overview

Restic REST Server is a dedicated HTTP server that provides a REST API backend for the Restic backup tool, enabling centralized backup storage over HTTP/HTTPS. Originally developed to offer a lightweight alternative to cloud storage backends, restic-rest-server allows organizations to maintain complete control over their backup infrastructure while providing the same deduplication and encryption benefits as cloud-based solutions. This stack combines restic-rest-server with Prometheus monitoring and Grafana visualization to create a comprehensive backup solution with full operational visibility. The integration leverages restic-rest-server's built-in Prometheus metrics endpoint to track backup operations, repository health, and storage utilization in real-time. This monitoring-enabled backup infrastructure is ideal for organizations that need reliable backup services with detailed operational insights, providing both the security of on-premises storage and the observability required for enterprise backup management.

## Features

- Built-in Prometheus metrics endpoint for backup operation monitoring
- Client-side AES-256 encryption with user-controlled keys
- Content-defined chunking for optimal deduplication ratios
- RESTful API supporting all Restic backup operations
- Real-time backup performance visualization through Grafana dashboards
- Repository integrity verification and corruption detection
- Multi-client support with concurrent backup operations
- Incremental backup tracking with detailed storage analytics

## Use cases

- Centralized backup server for multiple Linux servers with monitoring dashboards
- Docker container backup solution with operational metrics for DevOps teams
- Small business backup infrastructure replacing expensive commercial solutions
- Homelab backup system with professional-grade monitoring capabilities
- Development environment backup with detailed storage utilization tracking
- Branch office backup consolidation with central monitoring oversight
- Cloud exit strategy for organizations moving backup storage in-house

## Prerequisites

- Minimum 1GB RAM for optimal Restic deduplication performance
- Docker and Docker Compose installed on the host system
- Available ports 3000, 8000, and 9090 for service access
- Sufficient disk space for backup repository growth and time-series data
- Basic understanding of Restic backup concepts and repository initialization
- Network connectivity from backup clients to port 8000 on the Docker host

## docker-compose.yml

```yaml
services:
  restic-rest-server:
    image: restic/rest-server:latest
    environment:
      - OPTIONS=--prometheus --no-auth
    volumes:
      - restic-data:/data
    ports:
      - "8000:8000"
    networks:
      - restic-network
    restart: unless-stopped

  prometheus:
    image: prom/prometheus:latest
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --storage.tsdb.path=/prometheus
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus-data:/prometheus
    ports:
      - "9090:9090"
    networks:
      - restic-network
    restart: unless-stopped

  grafana:
    image: grafana/grafana:latest
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
    volumes:
      - grafana-data:/var/lib/grafana
    ports:
      - "3000:3000"
    depends_on:
      - prometheus
    networks:
      - restic-network
    restart: unless-stopped

volumes:
  restic-data:
  prometheus-data:
  grafana-data:

networks:
  restic-network:
    driver: bridge
```

## .env

```bash
# Restic REST Server
GRAFANA_PASSWORD=secure_grafana_password

# Initialize repo:
# restic -r rest:http://localhost:8000/myrepo init
```

## Usage notes

- REST server at http://localhost:8000
- Prometheus at http://localhost:9090
- Grafana at http://localhost:3000
- Initialize repo before use
- AES-256 encryption

## Troubleshooting

- Repository does not exist error: Initialize the repository using 'restic -r rest:http://localhost:8000/repo init' before first backup
- Prometheus metrics not appearing: Verify restic-rest-server started with --prometheus flag and check port 8000/metrics endpoint
- Grafana shows no data: Confirm prometheus.yml includes restic-rest-server target at restic-rest-server:8000
- High memory usage during backup: Adjust Restic's --limit-download and --limit-upload flags to reduce concurrent operations
- Permission denied on volumes: Check Docker volume permissions and ensure containers can write to mounted directories
- Connection refused from Restic client: Verify restic-rest-server is accessible on port 8000 and network connectivity is established

