I was trying to run a backup job periodically as a cron job. After initialsing the repo everthing is running correctly if I start my backup script manually (stripped down to a minimal example):
#!/bin/bash
export 'RESTIC_REPOSITORY=local:/tmp'
export 'RESTIC_PASSWORD=foo'
restic backup /etc
but running the same script as a cron job results in a endless hang with output of:
crond[1]: USER root pid 44 cmd /bin/cronscript
repository 318a33a7 opened successfully, password is correct
crond[1]: user root: process already running: /bin/cronscript
crond[1]: user root: process already running: /bin/cronscript
Steps to reproduce:
Build and use a Dockerfile like this:
FROM restic/restic
RUN apk --no-cache add strace
RUN echo "* * * * * /bin/cronscript" |crontab - && \
echo "#!/bin/ash" > /bin/cronscript && \
echo "export 'RESTIC_REPOSITORY=local:/tmp'" >> /bin/cronscript && \
echo "export 'RESTIC_PASSWORD=foo'" >> /bin/cronscript && \
echo "restic backup /etc" >> /bin/cronscript && \
chmod a+x /bin/cronscript
RUN export RESTIC_REPOSITORY=local:/tmp && export RESTIC_PASSWORD=foo && restic init
ENTRYPOINT crond -f
When I take a look with strace at the running restic process I get only this output:
/ # ps aux
PID USER TIME COMMAND
1 root 0:00 crond -f
13 root 0:00 sh
44 root 0:00 {cronscript} /bin/ash /bin/cronscript
45 root 0:06 restic backup /etc
55 root 0:00 ps aux
/ # strace -p 45
strace: Process 45 attached
clock_gettime(CLOCK_MONOTONIC, {tv_sec=360441, tv_nsec=77852481}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=360441, tv_nsec=80305781}) = 0
epoll_pwait(3, [], 128, 6127, NULL, 0) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=360447, tv_nsec=216650881}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=360447, tv_nsec=216957881}) = 0
epoll_pwait(3, [], 128, 9991, NULL, 0) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=360457, tv_nsec=218621681}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=360457, tv_nsec=218896281}) = 0
epoll_pwait(3, ^Cstrace: Process 45 detached
<detached ...>
Note:
(1) This example has been reduced to a minimum to present this strange behavior. My real script is actually much more complex and uses a remote restic rest-server as backup location. I reduced complexity and found out that this occurs only on alpine. With a Ubuntu docker image everything is okay. But I really would like to run this with alpineā¦especially with the ārestic/resticā image.
(2) You have to start the complied Dockerfile like this to be able to use strace:
docker run -ti --cap-add=SYS_PTRACE --security-opt seccomp=unconfined rt