Support

Akeeba Backup for Joomla!

#22121 Akeeba Cron Script not working

Posted in ‘Akeeba Backup for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Backup version
n/a

Latest post by marcelake on Monday, 02 March 2015 08:04 CST

marcelake
Dear Akeeba team,

I used to use your free Akeeba Backup extension for some time. Today I bought the Pro version because of some trouble with cron. Unfortunately, I didn't get it working again until know.

After a cron job has been executed, I receive the following e-mail:

##############################
Akeeba Backup CLI 4.1.2 (2015-02-03)
Copyright (C) 2010-2015 Nicholas K. Dionysopoulos
-------------------------------------------------------------------------------
Akeeba Backup is Free Software, distributed under the terms of the GNU General
Public License version 3 or, at your option, any later version.
This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the
license. See http://www.gnu.org/licenses/gpl-3.0.html for details.
-------------------------------------------------------------------------------
You are using PHP 5.3.29 (cli)

Starting a new backup with the following parameters:
Profile ID 1
Description "Command-line backup"

Current memory usage: 1.48 Mb

Unsetting time limit restrictions.

Site paths determined by this script:
JPATH_BASE : /is/htdocs/xyz/abc/joomla2
JPATH_ADMINISTRATOR : /is/htdocs/xyz/abc/joomla2/administrator

##############################

This is how my cron command looks like: abc/joomla2/cli/akeeba-backup.php

Host Europe has a special way to add cron jobs. So I only need to specify where the script is located. But I have to add #!/usr/bin/php to the top of every cron script (not only Akeeba).

Well, the cron part seems to work, otherwise the error message would be different.

I already tried it with the alternative Akeeba cron script, but I got a similar result:

##############################
Akeeba Backup Alternate CRON Helper Script version 4.1.2 (2015-02-03)
Copyright (C) 2010-2015 Nicholas K. Dionysopoulos
-------------------------------------------------------------------------------
Akeeba Backup is Free Software, distributed under the terms of the GNU General
Public License version 3 or, at your option, any later version.
This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the
license. See http://www.gnu.org/licenses/gpl-3.0.html for details.
-------------------------------------------------------------------------------
Unsetting time limit restrictions.

Site paths determined by this script:
JPATH_BASE : /is/htdocs/xyz/abc/joomla2
JPATH_ADMINISTRATOR : /is/htdocs/xyz/abc/joomla2/administrator
######################################

I also set up an execution time limit, but no success.

The manual backend backups work, no trouble there.

Could you please help me to get Akeeba working via cron job?

Thank you very much
Marcel

tampe125
Akeeba Staff
Hello Marcel,

can you please attach the error log? You might have to ask to your host to help you, since sometimes the CLI error log is not directly available.

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
Hi Davide,

thanks a lot for your reply! Which error log do you mean? The Akeeba_Backup_Debug_Log.zip is already attached to my initial post. I also have command line access (SSH) to my webhosting space.

tampe125
Akeeba Staff
I meant the PHP error_log: I suspect something wrong is happening, but I need to take a look at it to understand what's going on.

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
Would it help if I activate the Joomla error reporting and copy&paste the messages to this thread? Or is the PHP error log definitely something which I need to download somewhere (since you say I may need the help of my host)?

tampe125
Akeeba Staff
Yes, let's give it a try.

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
I did so. But I got no extra information. It came to my mind that we are talking about a cron job here. So the error messages come via e-mail. The Joomla error reporting is not very verbose here. ;)

The error log file of my webspace does not contain anything related to akeeba (I used the search function there).

What could we do?

tampe125
Akeeba Staff
Can you please try to force the debug mode by adding these lines to the cli file, immediately after the <?php tag?
define('AKEEBADEBUG', 1);
ini_set('display_errors', 1);
error_reporting(E_ALL);

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
Great, there are more information in the cron e-mails now:

Akeeba Backup CLI 4.1.2 (2015-02-03)
Copyright (C) 2010-2015 Nicholas K. Dionysopoulos
-------------------------------------------------------------------------------
Akeeba Backup is Free Software, distributed under the terms of the GNU General
Public License version 3 or, at your option, any later version.
This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the
license. See http://www.gnu.org/licenses/gpl-3.0.html for details.
-------------------------------------------------------------------------------
You are using PHP 5.3.29 (cli)

Starting a new backup with the following parameters:
Profile ID 1
Description "Command-line backup"

Current memory usage: 1.48 Mb

Unsetting time limit restrictions.

Site paths determined by this script:
JPATH_BASE : /is/htdocs/xyz/abc/joomla2
JPATH_ADMINISTRATOR : /is/htdocs/xyz/abc/joomla2/administrator


Fatal error: Uncaught exception 'RuntimeException' with message 'Could not connect to MySQL' in /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/engine/Driver/Mysqli.php:286
Stack trace:
#0 /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/engine/Driver/Base.php(1035): Akeeba\Engine\Driver\Mysqli->query()
#1 /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/engine/Driver/Base.php(728): Akeeba\Engine\Driver\Base->execute()
#2 /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/engine/Platform/Base.php(571): Akeeba\Engine\Driver\Base->loadAssocList()
#3 /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/engine/Platform.php(272): Akeeba\Engine\Platform\Base->get_running_backups(NULL)
#4 /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/en in /is/htdocs/xyz/abc/joomla2/administrator/components/com_akeeba/engine/Driver/Mysqli.php on line 286

tampe125
Akeeba Staff
Is the backup running in the backend? Can you please double check if there are any additional databases added to the same profile?

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
Hi Davide,

yes, creating backups in the backend works flawless. And there are no additional databases. Just the one Joomla database. I have attached my profile config file.

marcelake
... now with the config file.

tampe125
Akeeba Staff
I suspect there's a different PHP setup for CLI and web. Most likely your CLI PHP executable does not have support for mysql/mysqli or the host address is not reachable under CLI (ie you are using localhost but the database server requires an IP address).

I think you should contact your hosting about this issue, saying that you can't connect to the database under CLI.

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
Hi Davide,

I have been in contact with my webhoster. We have not yet solved the issue, but perhaps we have found the reason of the mysql error: My configuration.php is NOT located in the Joomla root folder (for security reasons)! And therefore the akeeba cron skript may not access the connection information at all?

So, maybe the path to the configuration.php is hard-coded in Akeeba - instead of looking into /includes/defines.php?

nicholas
Akeeba Staff
Manager
Please let me make this abundantly clear. There is absolutely no security reason whatsoever in any possible and conceivable universe for moving your configuration.php file outside the site's root. This is a myth. For the very detailed arguments please refer to my blog post "Keep your files where I can see them!" which I wrote all the way back in September 2012.

Since you followed the instructions to modify Joomla! to load a configuration.php file from outside your site's root you should have been told that you need three defines.php files for the three different Joomla! areas:

1. Your site's public front-end (in the site's root)
2. Your site's administrator backend (in the administrator directory)
3. Your site's CLI scripts (in the cli directory)

Apparently you forgot the third (or, typically, the person who wrote the instructions forgot all about it), which is a site configuration error. OK, you can fix it easily.

You should, however, be aware of the pitfalls for restoring a site with a moved configuration.php. It will be impossible for the installer script (ANGIE) to find the configuration.php file of the site since we're only looking at the site root. We cannot include defines.php to detect custom JPATH_CONFIGURATION folders, at least not without risking a white page of death should your defines.php reference something not available on the server where your site is now being restored to. Not finding a configuration.php is a nuissance you can work around, a white page of death means it's impossible to restore the site so that is why we chose to not load defines.php.

The result of not finding a configuration.php is that all values normally read from there will be reset to default and have to be entered from scratch in the ANGIE restoration script. Moreover, the generated configuration.php file in the site's root will be not read since defines.php tells it to read it from somewhere else. That "somewhere else" will not exist (if it's a new site) or will contain the old values (if it's the same site), so the restored site will not work without manual adjustments! At worst your site won't even load with "configuration.php not present and installation code not found", or it will loop back to the restoration script. At best your site will load, but it will be loading the wrong configuration. Which might not be the best case scenario.

This could become a nightmare scenario if you are cloning your site to create a dev site. Both sites will be reading the same configuration.php file, therefore both will be talking to the same database. Any change in the dev site will modify the live site and you will only find out when it is way too late. We've had people accuse us of being idiots or worse when this happened to them. However, this is a self-inflicted problem: we do warn you not to move your configuration.php file in our documentation. There's a good reason we do that.

My suggestion is to move your configuration.php file back to your site's root. There's no added security in storing it elsewhere.

One more thing. If someone says "do X for security reasons" don't rush into action. Ask them why and expect a detailed reply with reasonable arguments. If someone told you to do something pointless, e.g. start singing yama yama yama "for security reasons" would you do that? Of course not, that would be silly and have nothing to do with security. You see where I'm getting at? :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

marcelake
Hi Nicholas,

thank you very, very much for your extensive answer! I read your article about moving the configuration.php - and followed your arguments. The cron backups work now.

Cheers!
Marcel

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!