Closed YurNaybor closed 4 months ago
I've built a custom image based on cupcakearmy/autorestic:1.7.9 and only added docker-cli via apk. This was enough to come one step further. Autorestic now could find the volume and started a docker run command.
Unfortunately, this also failed without error message. At least it printed the command and I was able, by running it manually, to find out that apparently it did not run restic init before running restic backup. I'm not sure if that's an configuration issue on my side or Autorestic bug. Do I have to run restic init or autorestic check manually (initially) when using cron?
Running init manually solved it an now Autorestic seems to run trough fine.
Though I am not sure if there should be output after "Executing...forget"
Using config: /etc/autorestic/.autorestic.yml
Using env: /etc/autorestic/.autorestic.env
Using lock: /etc/autorestic/.autorestic.lock.yml
Backing up location "dummy"
Running hooks
> echo "Before"
> Executing: /bin/bash -c echo "Before"
Before
Backend: local
> Executing: /usr/bin/docker volume inspect autorestic_dummy-location
[
{
"CreatedAt": "2023-10-29T01:19:43-04:00",
"Driver": "local",
"Labels": {
"com.docker.stack.namespace": "autorestic"
},
"Mountpoint": "/var/lib/docker/165536.165536/volumes/autorestic_dummy-location/_data",
"Name": "autorestic_dummy-location",
"Options": {},
"Scope": "local"
}
]
> Executing: /usr/bin/docker run --rm --entrypoint ash --workdir /data --volume autorestic_dummy-location:/data --hostname docker --volume /backends/local:/repo --env RESTIC_REPOSITORY=/repo --env RESTIC_PASSWORD=topsecret cupcakearmy/autorestic:1.7.9 -c restic backup --tag ar:cron --tag ar:location:dummy /data
Running hooks
> echo "After"
> Executing: /bin/bash -c echo "After"
After
Running hooks
> echo "Something went wrong"
> Executing: /bin/bash -c echo "Something went wrong"
Something went wrong
root@xxx:/# /usr/bin/docker run --rm --entrypoint ash --workdir /data --volume autorestic_dummy-location:/data --hostname docker --volume /backends/local:/repo --env RESTIC_REPOSITORY=/repo --env RESTIC_PASSWORD=topsecret cupcakearmy/autorestic:1.7.9 -c "restic backup --tag ar:cron --tag ar:location:dummy /data"
Fatal: unable to open config file: stat /repo/config: no such file or directory
Is there a repository at the following location?
/repo
root@xxx:/# /usr/bin/docker run --rm --entrypoint ash --workdir /data --volume autorestic_dummy-location:/data --hostname docker --volume /backends/local:/repo --env RESTIC_REPOSITORY=/repo --env RESTIC_PASSWORD=topsecret cupcakearmy/autorestic:1.7.9 -c "restic init"
created restic repository b83abed212 at /repo
Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
root@xxx:/# /usr/bin/docker run --rm --entrypoint ash --workdir /data --volume autorestic_dummy-location:/data --hostname docker --volume /backends/local:/repo --env RESTIC_REPOSITORY=/repo --env RESTIC_PASSWORD=topsecret cupcakearmy/autorestic:1.7.9 -c "restic backup --tag ar:cron --tag ar:location:dummy /data"
no parent snapshot found, will read all files
Files: 2 new, 0 changed, 0 unmodified
Dirs: 1 new, 0 changed, 0 unmodified
Added to the repository: 846 B (564 B stored)
processed 2 files, 0 B in 0:00
snapshot eb58e720 saved
Using config: /etc/autorestic/.autorestic.yml
Using env: /etc/autorestic/.autorestic.env
Using lock: /etc/autorestic/.autorestic.lock.yml
Backing up location "dummy"
Running hooks
> echo "Before"
> Executing: /bin/bash -c echo "Before"
Before
Backend: local
> Executing: /usr/bin/docker volume inspect autorestic_dummy-location
[
{
"CreatedAt": "2023-10-29T01:19:43-04:00",
"Driver": "local",
"Labels": {
"com.docker.stack.namespace": "autorestic"
},
"Mountpoint": "/var/lib/docker/165536.165536/volumes/autorestic_dummy-location/_data",
"Name": "autorestic_dummy-location",
"Options": {},
"Scope": "local"
}
]
> Executing: /usr/bin/docker run --rm --entrypoint ash --workdir /data --volume autorestic_dummy-location:/data --hostname docker --volume /backends/local:/repo --env RESTIC_PASSWORD=topsecret --env RESTIC_REPOSITORY=/repo cupcakearmy/autorestic:1.7.9 -c restic backup --tag ar:cron --tag ar:location:dummy /data
Running hooks
> echo "After"
> Executing: /bin/bash -c echo "After"
After
Running hooks
> echo "Well done!"
> Executing: /bin/bash -c echo "Well done!"
Well done!
Forgetting for location "dummy"
For backend "local"
> Executing: /usr/bin/restic --cache-dir /cache forget --tag ar:location:dummy --prune --keep-daily 30 --keep-weekly 52
Describe the bug I did not managed to get backup of Docker volumes working with cupcakearmy/autorestic in Docker.
Expected behavior Autorestic backing up Docker volumes.
Environment
Additional context
Autorestic log:
Autorestic configuration:
Autorestic invocation (in container):
Docker volume listing:
If I read the code correctly, Autorestic uses the Docker CLI to interact with Docker. Now, the Docker CLI is not included in the image, thus this cannot work:
It is also strange to see no error message related to this in the Autorestic output. It's only the invocation of the failure hook ("Something went wrong") showing that there is an issue.