Skip to content

Weird issue with environment variables #568

@anacierdem

Description

@anacierdem

I'm trying to use some environment variables with my resticprofile setup. For more context I'm running resticprofile on docker and I mount my home folder to the container. When I use .Env.HOME like this:

default:
  password-file: /run/secrets/restic_password
  repository: 'rclone:drive:restic'
  initialize: false
  force-inactive-lock: true
  backup:
    source:
      - ./Documents
      - ./Downloads
      - ./Pictures
      - ./Videos
      - .config/autostart
      - .config/dconf
      - .config/monitors.xml
      - .ssh
      - .bash_profile
      - .bashrc
      - .gitconfig
      - .wakatime.cfg
      - .gitconfig
    source-base: {{ .Env.HOME }}
    source-relative: true

    exclude-caches: true
    exclude-file: /resticprofile/resticignore

    one-file-system: true
    schedule: '*-*-* *:26,45:00'
    schedule-permission: system
    skip-if-unchanged: true
    check-before: true
    dry-run: false
    verbose: true

Scheduled backups somehow try to backup /root/Documents etc. instead of my expected /var/home/user and fails to find the source locations. Running the same config inside the container via resticprofile backup works fine and also resticprofile show prints the correct path (/var/home/user).

It keeps failing with the docker entrypoint OTOH:

    command:
      - "-c"
      - "resticprofile schedule --all && crond -f"

I suspect this configuration is always running as "root" b/c of the schedule-permission. I'm writing this here to get a clarification if that's the case. I think this is expected thinking back I'm running the schedules as system, but it wasn't super clear to me that resticprofile uses the actual user's variables for .Env.HOME rather than my docker provided one:

    environment:
      - HOME=$HOME

Directly trying to execute echo $HOME as root on the container, does print /var/home/user so it is still not 100% clear what is going on for me. Changing docker command to echo $HOME is still not pointing at root so I think resticprofile is doing something here.

I'll now try with user permission. That configuration is more appropriate here, but let's see what it does.

One other curious thing is $HOME syntax doesn't work as advertised here. It is simply not replaced at all.

I'm on 0.30.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions