docker run not working with shell script


Recommended Posts

Hi there,

 

i want to do my backups with restic and rsync. So i setup a shell script that starts the container and does the backup.

But the docker run commands are not running properly when called by the script. It looks like there is some issue with variables given to the computer.

if i copy&paste them to the command line everything works. maybe someone can point my in the right direction to fix that problem.

 

 

 

Link to comment
docker run --rm -v $(pwd):/data -e RESTIC_REPOSITORY=s3:s3.amazonaws.com/bucket_name -e RESTIC_PASSWORD=my-secure-password 
           -e AWS_ACCESS_KEY_ID=my-aws-access-key -e AWS_SECRET_ACCESS_KEY=my-aws-secret-key instrumentisto/restic backup /data

 

thats the example call for the restic container. I just changed the needed parameters.

The script just contains these calls with different folders.

when i run the shell script this happens:

 

root@nas:/mnt/user/myscripts/resticNasBackup# ./resticBackuphtpc.sh
 does not exist, skipping
Fatal: all target directories/files do not exist
 does not exist, skipping
...

it looks like the when the script is executed the target vars are not set properly. i don't understand why.

 

if i copy and paste a single docker run call from the script to the console it is running, no issue.

root@nas:~# docker run --rm -v /mnt/user/fotos:/fotos -e RESTIC_REPOSITORY=s3:http://10.24.13.148:9000/backupnas -e RESTIC_PASSWORD= -e AWS_ACCESS_KEY_ID= -e AWS_SECRET_ACCESS_KEY= instrumentisto/restic --verbose backup /fotos
open repository
created new cache in /root/.cache/restic
lock repository
load index files
start scan on [/fotos]
start backup on [/fotos]

 

Edited by datun1c0rn
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.