Unable to make backup from mySQL

I have dolibarr 22.0.3 installed with docker on my machine. I am having some problems with the MySQL mysqldump backup that, when trying to make a new backup sends the message: “ERROR: unable to write in the directory”.
I am not understanding which directory is it referring to and why it can’t write.

When trying to backup from PHP I get sent to a page /admin/tools/export.php that gives a 500 error code.

Any help would be very, much appreciated.

Dolibarr is trying to create the backup in the …documents/admin/backup folder.
If that folder isn’t set with write permissions for the web user it will give the error.

You need to give permission to the web user.

Thanks, I have dolibarr installed with docker, so I assume the directories ad in the dolibarr-web container.

I looked into the logs and found these rows:

2026-03-14 20:47:01 INFO    151.43.201.244     1741   1000 files.lib.php::dol_dir_list path=/var/www/documents/admin/backup types=files recursive=0 filter="" excludefilter=""
2026-03-14 20:47:01 INFO    151.43.201.244     1741   1000 files.lib.php::dol_dir_list path=/var/www/documents/admin/documents types=files recursive=0 filter="" excludefilter=""
2026-03-14 20:47:01 INFO    151.43.201.244     1741   1000 --- End access to /admin/tools/dolibarr_export.php

So I also assumed the folders I needed to give it access to are here:

root@5988c0d7179a:/var/www/documents/admin# chgrp -R www-data backup
root@5988c0d7179a:/var/www/documents/admin# chgrp -R www-data documents 
root@5988c0d7179a:/var/www/documents/admin# ls -la
total 16
drwxr-xr-x  4 root     www-data 4096 Mar 14 20:48 .
drwxr-xr-x 24 www-data www-data 4096 Mar 14 20:40 ..
drwxr-xr-x  2 root     www-data 4096 Mar  2 02:03 backup
drwxr-xr-x  2 root     www-data 4096 Mar 14 20:48 documents
root@5988c0d7179a:/var/www/documents/admin# 

With this done the backups still don’t succeed.

okay, so in docker the users inside the docker container are different than the users outside the docker container.

If you mount a local disk from outside docker into the docker on that path inside the docker container, then you are mixing the users and permissions. This is possible, the easiest way is to make it world writeable for everyone - but that is also a dangerous security risk.

You can most likely map the users from outside docker to inside the docker container, but you need to specify that.

If you use docker volumes, then all this should not be necessary.

Thanks @jonbendtsen, I am not that skilled with docker; would you be able to tell me what I should do in practice?

Here is my docker-compose.yaml

services:
    mariadb:
        image: mariadb:latest
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
            MYSQL_DATABASE: ${MYSQL_DATABASE:-dolidb}
            MYSQL_USER: ${MYSQL_USER:-dolidbuser}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD:-dolidbpass}

        volumes:
            - /home/dolibarr_mariadb:/var/lib/mysql

    web:
        image: dolibarr/dolibarr:latest
        environment:
            DOLI_INIT_DEMO: ${DOLI_INIT_DEMO:-0}
            DOLI_DB_HOST: ${DOLI_DB_HOST:-mariadb}
            DOLI_DB_NAME: ${DOLI_DB_NAME:-dolidb}
            DOLI_DB_USER: ${DOLI_DB_USER:-dolidbuser}
            DOLI_DB_PASSWORD: ${DOLI_DB_PASSWORD:-dolidbpass}
            DOLI_URL_ROOT: "${DOLI_URL_ROOT:-http://0.0.0.0}"
            DOLI_ADMIN_LOGIN: "${DOLI_ADMIN_LOGIN:-admin}"
            DOLI_ADMIN_PASSWORD: "${DOLI_ADMIN_PASSWORD:-admin}"
            DOLI_CRON: ${DOLI_CRON:-0}
            DOLI_CRON_KEY: ${DOLI_CRON_KEY:-mycronsecurekey}
            DOLI_COMPANY_NAME: ${DOLI_COMPANY_NAME:-MyBigCompany}
            WWW_USER_ID: ${WWW_USER_ID:-1000}
            WWW_GROUP_ID: ${WWW_GROUP_ID:-1000}

        ports:
            - "80:80"
        links:
            - mariadb
        volumes:
            - /home/dolibarr_documents:/var/www/documents
            - /home/dolibarr_custom:/var/www/html/custom


What if you do a chmod a+rwx /home/dolibarr_documents/admin/backups/ from outside docker

Thank you! This worked. I also had to run chmod a+rwx /home/dolibarr_documents/admin/documents since it did the same for the files backup.

Good, but we are not done yet.

Take a look at the files in that directory, and the directory itself. Which user/user id are the owner and group of those files?

that would be the uid mapping between inside and outside Docker. The uid is a number and a number will be a number no matter where, but it may or may not correlate to the same username.

if it is just a number, then you could create a user outside docker with that user id and then you have a name, not just a number.