Docker compose question

Hi can anyone help me get started? I’m trying to configure the Restic docker compose but I don’t understand some things.

services:
  restic:
    container_name: restic
    image: lobaro/restic-backup-docker:latest
    hostname: dockervm
    privileged: true
    volumes:
      - /home/docker/esphome/data:/data/esphome:ro
    environment:
      - RESTIC_REPOSITORY=/home/docker/test1:/storage/dockervm
      - RESTIC_PASSWORD=XXX
      - BACKUP_CRON=0 22 * * 0
      - CHECK_CRON=0 22 * * 3
      - RESTIC_FORGET_ARGS=--prune --keep-last 4
    restart: always

I need to mount a volume for the files I want to backup right? so for instance my Esphome app store its files on /home/docker/esphome/data
so I need to mount that volume also in restic I believe?

And what is the purpose of Restic_repository? The destination where the backup will be saved?

And finally, what about the app files of Restic, the application itself? do I need a volume for that also? to have persistent storage.

Thanks

Isn’t that what you already did?

This Docker container running restic presumably needs that, yes, as otherwise it won’t have any files to back up :slight_smile:

Correct. It’s explained here: Preparing a new repository — restic 0.17.1 documentation

No, restic is (presumably - the Docker image you are using is not an official restic artifact but something created by a third party, so we really can’t answer for it) embedded in the Docker image you are running there, so you shouldn’t need anything else.

It seems that the image has documentation over here: GitHub - lobaro/restic-backup-docker: A docker container to automate backups with restic - I suggest you read that see how you can use it and configure it.

Here’s the docker compose file I use. I use a different distribution that adds a few extra features.

services:
  backup:
    image: mazzolino/restic
    hostname: docker
    restart: unless-stopped
    container_name: restic-backup
    environment:
      RUN_ON_STARTUP: "true"
      BACKUP_CRON: "0 30 3 * * *"
      RESTIC_REPOSITORY: s3:s3.amazonaws.com/bucketname
      RESTIC_PASSWORD: insert-here
      RESTIC_BACKUP_SOURCES: /docker /var/www/ /srv/
      RESTIC_COMPRESSION: max
      RESTIC_PACK_SIZE: 64
      RESTIC_BACKUP_ARGS: >-
        --exclude /docker/.git
        --exclude /srv/mysql/data
        --exclude *.gz
        --no-scan
        --cleanup-cache
      RESTIC_FORGET_ARGS: >-
        --keep-last 10
        --keep-daily 7
        --keep-weekly 8
        --keep-monthly 24
      AWS_ACCESS_KEY_ID: AK__________________
      AWS_SECRET_ACCESS_KEY: insert-here
      TZ: Pacific/Auckland
      PRE_COMMANDS: |-
        # The version of docker in the container is quite old and "docker compose" doesn't seem to work properly
        docker exec mysql mysqldump -u user -h 127.0.0.1 db_name > /srv/backups/backup-name.sql
      POST_COMMANDS_SUCCESS: |-
        # /my/scripts/mail-success.sh
      POST_COMMANDS_FAILURE: |-
        # echo "Restic docker backup FAILED" | mail -s "Restic Docker Backup FAILED" -aFrom:WildPi4Server5temp\<wildpi4server5temp@mrwild.co.nz\> web@mrwild.co.nz 
        # /my/scripts/mail-failure.sh
      POST_COMMANDS_INCOMPLETE: |-
        # echo "Restic docker backup incomplete" | mail -s "Restic Docker Backup Incomplete" -aFrom:WildPi4Server5temp\<wildpi4server5temp@mrwild.co.nz\> web@mrwild.co.nz 
        # /my/scripts/mail-incomplete.sh
    volumes:
      # local:container
      - /docker/:/docker/:ro
      - /srv/:/srv/
      - /var/www/:/var/www/:ro
      # This allows the container to interact with docker on the host machine
      - /var/run/docker.sock:/var/run/docker.sock

  prune:
    image: mazzolino/restic
    hostname: docker
    container_name: restic-prune
    restart: unless-stopped
    environment:
      SKIP_INIT: "true"
      RUN_ON_STARTUP: "false"
      # Prune at 4am on the 20th day of each month
      PRUNE_CRON: "0 0 4 20 * *"
      RESTIC_REPOSITORY:  s3:s3.amazonaws.com/bucket-name
      RESTIC_PASSWORD: insert-here
      AWS_ACCESS_KEY_ID: insert-here
      AWS_SECRET_ACCESS_KEY: insert-here
      TZ: Pacific/Auckland