Sorry for all the confusion here.
Yes, the HOME environment variable depends on the process that is running the php code. If PHP-FPM is enabled, it runs under the daemon user so it takes the configuration of that user when running the PHP code. This is the output of the ps aux command.
daemon 2346 0.0 1.3 266684 13492 ? S 09:11 0:00 php-fpm: pool mantis
As you can see in the
/etc/passwd file, the HOME folder of the daemon user is /usr/sbin
and the information that the PHP code provides is the following one
After stoping PHP-FPM and configuring Apache to run the PHP code, the PHP script is now run under the root user because Apache uses that user to start the server. In this case the output of the PHP code is the following one:
Could you please let us know who you configured the cronjob to run the backup script? Did you modify the script that you shared in this post?