Support

Akeeba Backup for Joomla!

#40678 Backup with Cronjob

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
5.1
PHP version
8.2
Akeeba Backup version
n/a

Latest post by nicholas on Thursday, 09 May 2024 01:25 CDT

Goggo

Hello,


We want to set up a cronjob-controlled backup with Akeeba Backup Pro.

/cli/akeeba-backup.php seems to stop working and returns an error. We cannot use remote.phar because the provider of course does not allow parameters such as "php remote.phar --action=backup --host=http://www.example.com --profile=2" via its interface.

What exactly is the procedure to simply initiate a backup with Cronjob?

Cheers,
Gregor

nicholas
Akeeba Staff
Manager

cli/akeeba-backup.php does not exist in Akeeba Backup 9 for Joomla! 4 and 5. Since you have Joomla! 5.1 and have not filled in any other fields, I assume that you have the old, discontinued Akeeba Backup 8 installed. Please upgrade to Akeeba Backup 9, then go to its Schedule Automatic Backups to find out about the new way to run CLI backups using Joomla's CLI application (cli/joomla.php).

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!

Goggo

Ok, no, we have installed Akeeba Backup 9.

I think most of managed hosting providers has no direct access to crontab and in many interface forms you can only insert a direct url call without params like "extension:task" etc. Seems for me, that joomla developers often only think in their boxes and server ressources.

How can I insert the params in a duplicate script of cli/joomla.php, to get it to work?

$app->input->set('akeeba:backup:take',1);

Goggo

The solution was simple, created a helper-script.

<?php

//Β  If parameters are to be passed, then a special script must be written for the cron job in which the call is carried out with parameters.Β This script can then be entered as a cron job in the customer menu.

$output = shell_exec('php '.dirname(__FILE__).'/joomla.php akeeba:backup:take');
echo "<pre>$output</pre>";

nicholas
Akeeba Staff
Manager

To be absolutely fair, what Joomla! is doing for CLI parameters is correct. The fact that it comes from me, who has a beef with a lot of the weird things Joomla does for nearly two decades, since it was called Mambo, says a lot, doesn't it?

Having CRON jobs which run a command line with parameters is something which first appeared in Vixie Cron back in 1987. Yes, that's really 37 years ago, it's not a typo. In fact, Cron is part of the IEEE standard Std1003.2-1992, commonly referred to as "POSIX". Note that there were other similar task schedulers which first appeared in the early 1970s, but they predated and did not conform to the POSIX standard. They all did allow you to run commands with parameters. That's the whole darned point of task scheduling!

To put it bluntly, if your host has not figured out how to offer real CRON jobs which have been around for at least 37 years, conforming to a standard which has been around the past 32 years, I would say that they are doing it wrong.

The usual way to work around subpar hosts like that is to create a bash script (shell script). For example, you could create the file do-backup.sh inside the cli path of your site with contents like this:

#!/usr/bin/env bash
/path/to/php `pwd`/joomla.php akeeba:backup:take

Then, give it executable permissions (0755) and you should be able to schedule a CRON job calling that script.

If that is not possible, then your server DOES NOT have real CRON jobs; they are merely calling a .php file over the web. That's okay-ish for basic WordPress sites, but that's not enough for any site which could legitimately claim to be based on "modern" design principles the last 20 years. Also note that while your workaround works for small, fast backups, it will fail when the backup time is higher than the PHP maximum execution time, or higher than the web server's timeout waiting for the output of PHP.

When you are up to an outright broken host like that (*cough* OVH *cough*) the only viable solutions, in order of best to worst, are: moving to a decent host, using a third party site monitoring software or service to execute the backup on a schedule, using Akeeba Remote CLI from a machine under your control, or using WebCRON.

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!

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!