djmaze / resticker

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

No valid operating mode configured! Exiting. #180

Open ALEX8642 opened 7 months ago

ALEX8642 commented 7 months ago

When running this docker compose file, I get the following repeating over and over:

appdata-restic-backup-1  | No valid operating mode configured! Exiting.
appdata-restic-backup-1  | Checking configured repository '/mnt/restic' ...
appdata-restic-backup-1  | Repository found.

The docker events call - docker daemon shows fatal error code 1 (repeating):

2024-01-21T19:19:33.804089963Z container die 1bd7160aac27f3d484a206aaf9901b552b8898ad0072f414f2c7eab00aac3922 (com.docker.compose.config-hash=7021956cb1867c24e682529d063ed8938c5b58415a6c263f279b27f36317648b, com.docker.compose.container-number=1, com.docker.compose.depends_on=, com.docker.compose.image=sha256:0804a5e5c3d422cbabcb4432bed6d77422c1addf7360eaae7b4e70171fad95f2, com.docker.compose.oneoff=False, com.docker.compose.project=appdata, com.docker.compose.project.config_files=/home/alex8642/appdata/docker-compose.yml, com.docker.compose.project.working_dir=/home/alex8642/appdata, com.docker.compose.service=restic-backup, com.docker.compose.version=2.21.0, execDuration=0, exitCode=1, image=mazzolino/restic, name=appdata-restic-backup-1)

Docker compose file:


    image: mazzolino/restic
    hostname: restic-backup
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - BACKUP_CRON=0 30 3 * * *
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=*********
      - RESTIC_BACKUP_SOURCES=/mnt/backup
    # RESTIC_BACKUP_ARGS: >-
    # --tag backup-tag
    # --exclude='folder/to/exclude'
    # --exclude='somefile.txt'
    # Keep docs: https://restic.readthedocs.io/en/stable/060_forget.html
      - RESTIC_FORGET_ARGS= >-
         --keep-daily 7
         --keep-weekly 5
         --keep-monthly 12
         --keep-yearly 3
         --keep-tag 'keep'
     #AWS_ACCESS_KEY_ID:
     #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC
    volumes:
      - ~/alex8642/ItbLab:/mnt/backup:ro
      - ./restic:/mnt/backup:rw

  restic-prune:
    image: mazzolino/restic
    hostname: restic-prune
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
 # Run once every month on the 30th day
      - PRUNE_CRON=0 30 3 * * *
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=*********
     #AWS_ACCESS_KEY_ID:
     #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC

  restic-check:
    image: mazzolino/restic
    hostname: restic-check
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
     # Run once every month on the 30th day
      - PRUNE_CRON=0 30 3 * * *
      - RESTIC_CHECK_ARGS= >-
         --read-data-subset=10%
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=*********
     #AWS_ACCESS_KEY_ID:
     #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC

    minio:
    image: ghcr.io/imagegenius/minio
    hostname: minio
    restart: unless-stopped
    ports:
      - 9001:9001 # web ui
      - 9000:9000 # api port
    environment:
      - MINIO_ROOT_USER=user
      - MINIO_ROOT_PASSWORD=********* # must be longer than 8
      - PUID=99
      - PGID=100
      - UMASK=022
    volumes:
      - ./minio:/config # bucket storage```
pelag0s commented 7 months ago

@ALEX8642 You have a command configured, that is wrong. Resticker is completely configured via env variables.

ALEX8642 commented 7 months ago

@ALEX8642 You have a command configured, that is wrong. Resticker is completely configured via env variables.

@pelag0s Ok. Incidentally enough though, that was an attempt to solve the issue. I did not have commands previously and it had zero impact on the error. I have confirmed once again. Updating original issue post to remove command section. Am I missing any env variables?

escoand commented 7 months ago

Look at the line with minio. There seems to be a incorrect indentation.

ALEX8642 commented 7 months ago

Look at the line with minio. There seems to be a incorrect indentation.

@escoand MinIO is working fine (GUI is fully accessible), so I don't think that's the issue.

escoand commented 7 months ago

You deployed it exactly like you copy-pasted? Hard to believe it is working with this config. So we could just guess what's the real problem.

escoand commented 7 months ago

I'm also quite sure this is also not working as intended:

   - RESTIC_FORGET_ARGS= >-
       ...

I suppose it was copied/converted from something like this:

    RESTIC_FORGET_ARGS: >=
      ...

Or use it like this:

   - >-
      RESTIC_FORGET_ARGS=
      ...
ALEX8642 commented 7 months ago

I'm also quite sure this is also not working as intended:

   - RESTIC_FORGET_ARGS= >-
       ...

I suppose it was copied/converted from something like this:

    RESTIC_FORGET_ARGS: >=
      ...

Or use it like this:

   - >-
      RESTIC_FORGET_ARGS=
      ...

@escoand a friend of mine provided this yaml. There other syntax issues solved already but they didn't change the error. I will change the syntax as you have indicated when I am able tonight and let you know. Appreciate the feedback. As mentioned though, minIO and all my other containers seem to be working OK. It's only Restic backup that gives me that error and goes into a restart loop.

djmaze commented 7 months ago

Also there is something missing at the beginning. I would expect something like this:

services:
  restic-backup:
    image: mazzolino/restic
    # ...

Let's shorten this discussion, here is your config with (hopefully) all the indentation errors fixed:

services:
  restic-backup:
    image: mazzolino/restic
    hostname: restic-backup
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - BACKUP_CRON=0 30 3 * * *
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=*********
      - RESTIC_BACKUP_SOURCES=/mnt/backup
      # RESTIC_BACKUP_ARGS: >-
      # --tag backup-tag
      # --exclude='folder/to/exclude'
      # --exclude='somefile.txt'
      # Keep docs: https://restic.readthedocs.io/en/stable/060_forget.html
      - RESTIC_FORGET_ARGS= >-
         --keep-daily 7
         --keep-weekly 5
         --keep-monthly 12
         --keep-yearly 3
         --keep-tag 'keep'
      #AWS_ACCESS_KEY_ID:
      #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC
    volumes:
      - ~/alex8642/ItbLab:/mnt/backup:ro
      - ./restic:/mnt/backup:rw

  restic-prune:
    image: mazzolino/restic
    hostname: restic-prune
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - PRUNE_CRON=0 30 3 * * *
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=*********
      #AWS_ACCESS_KEY_ID:
      #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC

  restic-check:
    image: mazzolino/restic
    hostname: restic-check
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - PRUNE_CRON=0 30 3 * * *
      - RESTIC_CHECK_ARGS= >-
         --read-data-subset=10%
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=*********
      #AWS_ACCESS_KEY_ID:
      #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC

  minio:
    image: ghcr.io/imagegenius/minio
    hostname: minio
    restart: unless-stopped
    ports:
      - 9001:9001 # web ui
      - 9000:9000 # api port
    environment:
      - MINIO_ROOT_USER=user
      - MINIO_ROOT_PASSWORD=********* # must be longer than 8
      - PUID=99
      - PGID=100
      - UMASK=022
    volumes:
      - ./minio:/config # bucket storage   
ALEX8642 commented 7 months ago

Hi. The changes made per @djmaze and @escoand had no effect. Error persists.

escoand commented 7 months ago

We need the actual used yaml. Currently it's just guesswork.

ALEX8642 commented 7 months ago

As a side note, there are other containers running in this all working great. I only pasted the section related to restic. This is why the services title was not present in previous versions. That was always present in the docker compose yaml. usernames and passwords removed for obvious reasons. I tried what @escoand recommended with the >- syntax first on the args.

---
version: "2.1"
services:
  restic-backup:
    image: mazzolino/restic
    hostname: restic-backup
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - BACKUP_CRON=0 30 3 * * *
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=
      - RESTIC_BACKUP_SOURCES=/mnt/backup
      # RESTIC_BACKUP_ARGS: >-
      # --tag backup-tag
      # --exclude='folder/to/exclude'
      # --exclude='somefile.txt'
      # Keep docs: https://restic.readthedocs.io/en/stable/060_forget.html
      - >-
         RESTIC_FORGET_ARGS=
         --keep-daily 7
         --keep-weekly 5
         --keep-monthly 12
         --keep-yearly 3
         --keep-tag 'keep'
      #AWS_ACCESS_KEY_ID:
      #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC
    volumes:
      - ~/alex8642/ItbLab:/mnt/backup:ro
      - ./restic:/mnt/backup:rw

  restic-prune:
    image: mazzolino/restic
    hostname: restic-prune
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - PRUNE_CRON=0 30 3 * * *
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=
      #AWS_ACCESS_KEY_ID:
      #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC

  restic-check:
    image: mazzolino/restic
    hostname: restic-check
    restart: unless-stopped
    environment:
      - RUN_ON_STARTUP=true
      # Run once every month on the 30th day
      - PRUNE_CRON=0 30 3 * * *
      - >-
        RESTIC_CHECK_ARGS=
         --read-data-subset=10%
      - RESTIC_REPOSITORY=s3:http://minio:9000/test-restic-backup
      - RESTIC_PASSWORD=
      #AWS_ACCESS_KEY_ID:
      #AWS_SECRET_ACCESS_KEY:
      - TZ=Etc/UTC

  minio:
    image: ghcr.io/imagegenius/minio
    hostname: minio
    restart: unless-stopped
    ports:
      - 9001:9001 # web ui
      - 9000:9000 # api port
    environment:
      - MINIO_ROOT_USER=
      - MINIO_ROOT_PASSWORD= # must be longer than 8
      - PUID=99
      - PGID=100
      - UMASK=022
    volumes:
      - ./minio:/config # bucket storage
escoand commented 7 months ago

And is it working now? By the way, you can do this also with only one container.

ALEX8642 commented 7 months ago

And is it working now? By the way, you can do this also with only one container.

Hi. The changes made per @djmaze and @escoand had no effect. Error persists.

^^^see my earlier comment where I said it did not work and then you asked for YAML. I have not changed the YAML since this comment.

re: one container - and? Feel free to elaborate. I'm looking for solutions here. :)

escoand commented 7 months ago

I'm using RESTIC_FORGET_ARGS=--prune ... to avoid the special prune container.

To the initial problem: I'm out of glue.

ALEX8642 commented 7 months ago

I'm using RESTIC_FORGET_ARGS=--prune ... to avoid the special prune container.

To the initial problem: I'm out of glue.

Gotcha. Thanks for your input. Hopefully @djmaze or @pelag0s has some ideas? Otherwise I'm pretty well out of ideas too. I was already at this for some time before starting the issue thread.

djmaze commented 7 months ago

Your configuration also mounts 2 directories at /mnt/backup. That does not make sense.

Also, I tried the restic-backup part of your yaml locally (without the volumes) and it worked for me. Maybe you are still using an old version of the mazzolino/restic image? Did you try docker pull mazzolino/restic?

ALEX8642 commented 7 months ago

Your configuration also mounts 2 directories at /mnt/backup. That does not make sense.

Also, I tried the restic-backup part of your yaml locally (without the volumes) and it worked for me. Maybe you are still using an old version of the mazzolino/restic image? Did you try docker pull mazzolino/restic?

I pulled latest image, then I tried it with all volumes deleted and the error persists. :(

ALEX8642 commented 7 months ago

Your configuration also mounts 2 directories at /mnt/backup. That does not make sense. Also, I tried the restic-backup part of your yaml locally (without the volumes) and it worked for me. Maybe you are still using an old version of the mazzolino/restic image? Did you try docker pull mazzolino/restic?

I pulled latest image, then I tried it with all volumes deleted and the error persists. :(

Alright so finally progress... Doing a complete update/upgrade of ubuntu server and docker, then restarting and running docker compose seems to have eliminated the initial error, though nothing is backing up it seems still... the log shows


restic-backup-1  | Checking configured repository 's3:http://minio:9000/test-restic-backup' ...
restic-backup-1  | Fatal: unable to open config file: Stat: Access Denied.
restic-backup-1  | Is there a repository at the following location?
restic-backup-1  | s3:http://minio:9000/test-restic-backup
restic-backup-1  | Could not access the configured repository. Trying to initialize (in case it has not been initialized yet) ...
restic-backup-1  | Fatal: create key in repository at s3:http://minio:9000/test-restic-backup failed: Stat: Access Denied.
restic-backup-1  |
restic-backup-1  | Initialization failed. Please see error messages above and check your configuration. Exiting.
restic-backup-1  | Checking configured repository 's3:http://minio:9000/test-restic-backup' ...```
ALEX8642 commented 7 months ago

Well I added user and key from Minio to (comment out pound removed)

AWS_ACCESS_KEY_ID:
AWS_SECRET_ACCESS_KEY:

Did not work either...

restic-backup-1  | Initialization failed. Please see error messages above and check your configuration. Exiting.
restic-backup-1  | Checking configured repository 's3:http://minio:9000/test-restic-backup' ...
restic-backup-1  | Fatal: unable to open config file: Stat: Access Denied.
restic-backup-1  | Is there a repository at the following location?
restic-backup-1  | s3:http://minio:9000/test-restic-backup
restic-backup-1  | Could not access the configured repository. Trying to initialize (in case it has not been initialized yet) ...
restic-backup-1  | Checking configured repository 's3:http://minio:9000/test-restic-backup' ...
restic-backup-1  | Fatal: unable to open config file: Stat: Access Denied.
restic-backup-1  | Is there a repository at the following location?
restic-backup-1  | s3:http://minio:9000/test-restic-backup
restic-backup-1  | Could not access the configured repository. Trying to initialize (in case it has not been initialized yet) ...
restic-backup-1  | Checking configured repository 's3:http://minio:9000/test-restic-backup' ...
danielr1996 commented 2 months ago

The error is thrown at https://github.com/djmaze/resticker/blob/master/entrypoint#L85 when the BACKUP_CRON variable isn't set. I don't know if this check is even necessary because it would be perfectly fine to run the image once and never again (e.g. user scheduled backup after an important change or otherwise triggering e.g. with kubernetes cronjob), however I think at least the error message could be clearer

djmaze commented 1 month ago

If there is not any _CRON variable set, it is unclear what the image should do. I would rather not run the backup as a default, as this could be a configuration mistake as well.

I'd rather improve the error message.