Linuxpad

Got Linux?

How to Run Restic Backup Server in Docker

How to Run Restic Backup Server in Docker
Photo by Taylor Vick / Unsplash

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.

Why Restic?

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. I will only go through how to quickly deploy this tool using docker. Create your compose.yaml file and paste this code:

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: Afiaanimah*123
      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: replace_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: replace_me
      TZ: Europe/London
    security_opt:
      - no-new-privileges:true

You can list available snapshots with this code:

nana@nana:~/docker/restic$ docker exec restic restic snapshots
ID        Time                 Host        Tags            Paths                Size
-------------------------------------------------------------------------------------------
5ff2c11a  2026-02-28 06:49:05  nana        docker-volumes  /home/nana/docker    562.947 KiB
                                                           /mnt/docker-volumes
-------------------------------------------------------------------------------------------
1 snapshots
nana@nana:~/docker/restic$ 

The Restic REST server in Docker provides a centralized, secure backup target for all your machines.  With scheduled backups on clients and server-side retention policies, you get a complete backup infrastructure that runs unattended.