Linuxpad

Got Linux?

How to Run Restic Backup Server in Docker

How to Run Restic Backup Server in Docker

Restic is a fast, secure backup program that supports encrypted, deduplicated backups to various storage backends. The Restic REST server provides an HTTP-based backend that multiple machines can back up to over the network. Running the REST server in Docker gives you a centralized backup target that is easy to deploy and manage. This guide covers server setup, client configuration, and operational best practices. Restic stands out from other backup tools for several reasons. It is fast because it processes data in parallel. It is efficient because block-level deduplication means identical data is stored only once, even across different backup sources. Encryption is mandatory, not optional, so every backup is protected with AES-256. The REST server adds network accessibility, letting any machine with the Restic client send backups to your central server.

This guide does not cover Client Setup or Initializing a Repository. Create your docker-compose.yaml file and paste this code snippet:

version: "3.3"

services:
  backup:
    image: mazzolino/restic
    container_name: restic
    hostname: nana
    environment:
      RUN_ON_STARTUP: "true" #change as you wish
      BACKUP_CRON: "0 */12 * * *" #this is twice daily, i.e., every 12 hours
      RESTIC_REPOSITORY: /restic
      RESTIC_PASSWORD: change_me
      RESTIC_BACKUP_SOURCES: /mnt/docker-volumes  /home/nana/docker
      RESTIC_COMPRESSION: auto 
      RESTIC_BACKUP_ARGS: >-
        --tag docker-volumes
        --exclude some-folder/cache
        --exclude another-folder/with\ space
        --exclude *.tmp
        --verbose
      RESTIC_FORGET_ARGS: >- #change as required
        --keep-last 10
        --keep-daily 7
        --keep-weekly 5
        --keep-monthly 12
      TZ: Europe/London
    volumes:
      - /home/nana/docker/nas/backup:/restic #change the left hand side to where you want to store the backups. As you can see I'm storing it on my NAS that is mounted to the host /home/truenas
      - /home/nana/docker/nas/tmp-for-restore:/tmp-for-restore #USE THIS FOLDER FOR RESTORE - CAN VIEW EACH CONTAINER
      - /var/lib/docker/volumes:/mnt/docker-volumes:ro
      - /home/nana/docker:/home/nana/docker:ro
    security_opt:
      - no-new-privileges:true

  prune:
    image: mazzolino/restic
    container_name: restic-prune
    hostname: nana
    environment:
      RUN_ON_STARTUP: "true"
      PRUNE_CRON: "0 0 4 * * *"
      RESTIC_REPOSITORY: /restic
      RESTIC_PASSWORD: change_me
      TZ: Europe/London
    security_opt:
      - no-new-privileges:true

  check:
    image: mazzolino/restic
    container_name: restic-check
    hostname: nana
    environment:
      RUN_ON_STARTUP: "false"
      CHECK_CRON: "0 15 5 * * *"
      RESTIC_CHECK_ARGS: >-
        --read-data-subset=10%
      RESTIC_REPOSITORY: /restic
      RESTIC_PASSWORD: change_me
      TZ: Europe/London
    security_opt:
      - no-new-privileges:true

Snapshot Management:

snapshots:



[nana@nana ~]$ docker exec restic restic snapshots
ID        Time                 Host        Tags            Paths                Size
-------------------------------------------------------------------------------------------
7f296cc6  2026-03-24 18:18:13  nana        docker-volumes  /home/nana/docker    955.402 KiB
                                                           /mnt/docker-volumes

cd168c54  2026-03-25 12:00:00  nana        docker-volumes  /home/nana/docker    1.144 MiB
                                                           /mnt/docker-volumes

ba1ad900  2026-03-26 00:00:00  nana        docker-volumes  /home/nana/docker    1.310 MiB
                                                           /mnt/docker-volumes

8716277d  2026-03-26 12:00:00  nana        docker-volumes  /home/nana/docker    1.516 MiB
                                                           /mnt/docker-volumes

7182dfe8  2026-03-27 00:00:00  nana        docker-volumes  /home/nana/docker    1.760 MiB
                                                           /mnt/docker-volumes

d1671e6f  2026-03-27 12:00:00  nana        docker-volumes  /home/nana/docker    2.043 MiB
                                                           /mnt/docker-volumes

0c528ba4  2026-03-28 00:00:00  nana        docker-volumes  /home/nana/docker    2.365 MiB
                                                           /mnt/docker-volumes

9411f453  2026-03-28 12:00:00  nana        docker-volumes  /home/nana/docker    2.728 MiB
                                                           /mnt/docker-volumes

88e10e19  2026-03-29 00:00:00  nana        docker-volumes  /home/nana/docker    3.130 MiB
                                                           /mnt/docker-volumes

39a82eac  2026-03-29 12:00:00  nana        docker-volumes  /home/nana/docker    3.581 MiB
                                                           /mnt/docker-volumes

04bb68fc  2026-03-30 00:00:00  nana        docker-volumes  /home/nana/docker    4.072 MiB
                                                           /mnt/docker-volumes
-------------------------------------------------------------------------------------------
11 snapshots


Output shows each snapshot with its ID, timestamp, hostname, paths, and tags:

Restore an entire snapshot or specific files:

# Restore the latest snapshot to a target directory
restic restore latest --target /tmp/restore

# Restore a specific snapshot by ID
restic restore a1b2c3d4 --target /tmp/restore

# Restore a specific file or directory
restic restore latest --target /tmp/restore --include "/var/www/app"

With scheduled backups on clients and server-side retention policies, you get a complete backup infrastructure that runs unattended.