[SOLVED] Backup "permission denied"?

I am trying to create backup/restore scripts for my apps but I always have the error:

Executing script...
/bin/bash: 50-dockercontainer__2: Permission denied

Here is the link to my script: https://github.com/scith/docker_container_ynh/blob/master/scripts/backup


name=$(sudo yunohost app setting $app name)
repository=$(sudo yunohost app setting $app repository)
datacontainer=$(sudo yunohost app setting $app datacontainer)

# The parameter $1 is the backup directory location which will be compressed afterward
    sudo mkdir -p $backup_dir

# Backup container's volumes
    if [ "$datacontainer" = "Yes" ];
        echo 'Backing up with data container'
        sudo docker stop $name
        sudo docker stop $name-data
        sudo docker run --rm --volumes-from $name-data -v $backup_dir:/backup $repository tar cvf /backup/container-$name.tar
        echo 'Backing up without data container'
        sudo docker stop $name
        docker run --rm --volumes-from $name -v $backup_dir:/backup $repository tar cvf /backup/container-$name.tar

# Copy the systemd service
    sudo cp -a /etc/systemd/system/container-$name.service $backup_dir/container-$name.service

# Copy YunoHost parameters
    sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost

Is there something wrong with it?


Check the user of the script. I had a similar issue with the roundcube backup script and running the following fixed it:

chown admin /etc/yunohost/hooks.d/backup/50-roundcube

1 Like

Thanks, that was it!