djmaze / resticker

Run automatic restic backups via a Docker container.
https://hub.docker.com/r/mazzolino/restic/
Apache License 2.0
511 stars 70 forks source link

Fatal: unable to open config file: stat /mnt/external/restic/config: no such file or directory #200

Open robertstrom opened 3 months ago

robertstrom commented 3 months ago

I have two working backups using these docker containers. One fully working backup to Backblaze using S3 buckets and one partially working that backs up the same data to an external direct attached storage NAS.

The containers are both running on the same QNAP NAS.

When I say fully working above I mean that all three containers / container functions (backup, prune, and check) are starting and working without error. The partially working scenario is backing up without issue but both the prune and check containers are having issues finding the repository config file.

Here is what the functioning backup logs to the external direct attached NAS look like:

Checking configured repository '/mnt/external/restic' ...
Repository found.

Executing backup on startup ...

Starting Backup at 2024-07-13 17:27:17
open repository
lock repository
using parent snapshot 5c9a1ce2
load index files
start scan on [/mnt/restic]
start backup on [/mnt/restic]
scan finished in 36.511s: 251343 files, 2.964 TiB

Files:           0 new,     2 changed, 251341 unmodified
Dirs:            0 new,    13 changed, 23196 unmodified
Data Blobs:      2 new
Tree Blobs:     13 new
Added to the repository: 11.877 MiB (5.870 MiB stored)

processed 251343 files, 2.964 TiB in 1:56
snapshot de015c2c saved
Backup successful
Finished backup at 2024-07-13 17:29:14 after 117 seconds

Scheduling backup job according to cron expression.
new cron: 0 30 7 * * *

This log, and the resulting backup, appears to clearly show that the repository (and therefor the config file) has been found.

Here is what the logs look like for the check container:

Checking configured repository '/mnt/external/restic' ...
Fatal: unable to open config file: stat /mnt/external/restic/config: no such file or directory
Is there a repository at the following location?
/mnt/external/restic
Could not access the configured repository.
Not trying to initialize because SKIP_INIT is set in your configuration..

Scheduling check job according to cron expression.
new cron: 0 15 9 * * *

Here is what the logs look like for the prune container:

Checking configured repository '/mnt/external/restic' ...
Fatal: unable to open config file: stat /mnt/external/restic/config: no such file or directory
Is there a repository at the following location?
/mnt/external/restic
Could not access the configured repository.
Not trying to initialize because SKIP_INIT is set in your configuration..

Scheduling prune job according to cron expression.
new cron: 0 0 8 * * *

Yet I can run both the check and prune jobs successfully, manually, from the command line.

Running the check job manually:

docker compose run --rm backup check

image

Running the prune job manually:

docker compose run --rm backup prune
image

Here is a screenshot showing the config file that cannot be found:

image

My docker compose file looks like this:

[rstrom@NASF8629F external-docker-backup]$ cat docker-compose.yaml
version: "3.3"

services:
  backup:
    image: mazzolino/restic
    hostname: restic-docker-backup-external
#    restart: unless-stopped
    restart: always
    environment:
      RUN_ON_STARTUP: "true"
      BACKUP_CRON: "0 30 7 * * *"
      RESTIC_REPOSITORY: /mnt/external/restic
      RESTIC_PASSWORD: <redacted>
      RESTIC_BACKUP_SOURCES:  /mnt/restic
      RESTIC_BACKUP_ARGS: >-
        --tag qnap-rstrom-home-drive
        --exclude *.tmp
        --verbose
      TZ: America/Los_Angeles
    volumes:
      - /share/CACHEDEV1_DATA/homes/rstrom:/mnt/restic
      - /share/TerraMaster/qnaprestic:/mnt/external

  prune:
    image: mazzolino/restic
    hostname: restic-docker-prune-external
    restart: unless-stopped
    environment:
      SKIP_INIT: "true"
      RUN_ON_STARTUP: "false"
      PRUNE_CRON: "0 0 8 * * *"
      RESTIC_PRUNE_ARGS: >-
        --verbose
      RESTIC_REPOSITORY: /mnt/external/restic
      RESTIC_PASSWORD: <redacted>
      TZ: America/Los_Angeles

  check:
    image: mazzolino/restic
    hostname: restic-docker-check-external
    restart: unless-stopped
    environment:
      SKIP_INIT: "true"
      RUN_ON_STARTUP: "false"
      CHECK_CRON: "0 15 9 * * *"
      RESTIC_CHECK_ARGS: >-
        --read-data-subset=10%
        --verbose
      RESTIC_REPOSITORY: /mnt/external/restic
      RESTIC_PASSWORD: <redacted>
      TZ: America/Los_Angeles
[rstrom@NASF8629F external-docker-backup]$

This job was created by copying the known working Backblaze docker-compose.yaml file and then modifying it to point to the external direct attached storage. The backup to the external storage works fine. I have tested mounting the backup on the external storage and navigating the backup file structure. It is only the prune and check portions of this that are not working.

I have been over the docker-compose.yaml file many, many times and I cannot find anything wrong with it.

Can someone, anyone, please tell me if there is something wrong with my configuration or if there is some bug that is causing this issue?

Thanks!

djmaze commented 3 months ago

The docker compose file defines 3 different services, and you need to define the volume attachments for every service. So you need to add the volumes section to the prune and check sections as well.

robertstrom commented 3 months ago

The docker compose file defines 3 different services, and you need to define the volume attachments for every service. So you need to add the volumes section to the prune and check sections as well.

I have made the modification and added the volumes section to the prune and check sections and that appears to be working now.

As I mentioned, I copied the basic docker-compose.yaml file from a functioning Backblaze backup that I have configured using this project. Everything about that backup, prune, and check is working without any errors for the Backblaze backup and there are no entries for the volumes in the prune or check sections of the docker-compose.yaml file for that backup. I'm curious why there is a difference.

Thanks for the response! I've played around with Docker some but this project has helped me learn more about using Docker and it has helped me take a fairly crappy backup solution for my QNAP NAS and turn it into a robust and reliable solution.

Thanks for the great project!

djmaze commented 3 months ago

check and prune both only need access to the repository. In the backblaze case, it's a remote repository so no docker volume is needed.