Support

Documentation

Automating your backup

Taking backups automatically

Even though the application makes it very easy to take a backup of your site, it still requires you to log in to Akeeba Solo or your site (if you are using Akeeba Backup), click on the Backup Now button and wait for the backup to finish. If you do this daily, it is a drag. Our job is to automate your life, making repeated and time consuming procedures a breeze. To this end we offer not just one, but 3 (yes, THREE!) different backup automation possibilities for the application.

Front-end backup, for use with CRON

The front-end backup feature is intended to provide the capability to perform an unattended, scheduled backups of your site.

The front-end backup URL performs a single backup step and sends a redirection (HTTP 302) header to force the client to advance to the next page, which performs the next step and so forth. You will only see a message upon completion, should it be successful or not. There are a few limitations, though:

  • It is not designed to be run from a normal web browser, but from an unattended cron script, utilizing wget or cron as a means of accessing the function.

  • The script is not capable of showing progress messages.

  • Normal web browsers tend to be "impatient". If a web page returns a bunch of redirection headers, the web browser thinks that the web server has had some sort of malfunction and stop loading the page. It will also show some kind of "destination unreachable" message. Remember, these browsers are meant to be used on web pages which are supposed to show some content to a human. This behaviour is normal. Most browsers will quit after they encounter the twentieth page redirect response, which is bound to happen. Please do not report that Firefox, Internet Explorer, Chrome, Safari, Opera or another browser doesn't work with the front-end backup feature. It was NOT meant to work by design.

  • Command line utilities, by default, will also give up loading a page after it has been redirected a number of times. For example, wget gives up after 20 redirects, curl does so after 50 redirects. Since Akeeba Solo redirects once for every step, it is advisable to configure your command line utility with a large number of redirects; about 10000 should be more than enough for virtually all sites.

[Tip]Tip

Do you want to automate your backups despite your host not supporting CRON? Webcron.org fully supports Akeeba Solo's front-end backup feature and is dirt cheap - you need to spend about 1 Euro for 1000 backup runs. Just make sure you set up your Webcron CRON job time limit to be at least 10% more than the time it takes for Akeeba Solo to backup your site. Don't know how much is that? No problem! Just take a regular backup from your site's back-end, then go to Manage Backups (formerly "Administer Backup Files") page and take a look at the Duration column. That's what you're looking for!

Before beginning to use this feature, you must set up Akeeba Solo to support the front-end backup option. First, go to Akeeba Solo's main page and click on the System Configuration button. Find the option titled Enable front-end and remote backups and set it to Yes. Below it, you will find the option named Secret key. In that box you have to enter a password which will allow your CRON job to convince Akeeba Solo that it has the right to request a backup to be taken. Think of it as the password required to enter the VIP area of a night club. After you're done, click the Save & Close button on top to save the settings and close the dialog.

[Tip]Tip

Use only lower- and upper-case alphanumeric characters (0-9, a-z, A-Z) in your secret key. Other characters may need to be manually URL-encoded in the CRON job's command line. This is error prone and can cause the backup to never start even though you'll be quite sure that you have done everything correctly.

Most hosts offer a CPanel of some kind. There has to be a section for something like "CRON Jobs", "scheduled tasks" and the like. The help screen in there describes how to set up a scheduled job. One missing part for you would be the command to issue. Simply putting the URL in there is not going to work.

[Warning]Warning

If your host only supports entering a URL in their "CRON" feature, this will most likely not work with Akeeba Solo. There is no workaround. It is a hard limitation imposed by your host. We would like to help you, but we can't. As always, the only barrier to the different ways we can help you is server configuration.

If you are on a UNIX-style OS host (usually, a Linux host) you most probably have access to a command line utility called wget. It's almost trivial to use:

wget --max-redirect=10000 "http://www.yoursite.com/index.php?

view=remote&key=YourSecretKey"

For Akeeba Backup for WordPress you should instead use

wget --max-redirect=10000 "http://www.yoursite.com/wp-admin/admin-ajax.php?

action=akeebabackup_legacy&key=YourSecretKey"

Of course, the line breaks are included for formatting clarity only. You should not have a line break in your command line!

[Important]Important

Do not miss the --max-redirect=10000 part of the wget command! If you fail to include it, the backup will not work with wget complaining that the maximum number of redirections has been reached. This is normal behavior, it is not a bug.

[Important]Important

YourSecretKey must be URL-encoded. You can use an online tool like http://www.url-encode-decode.com or simply consult the Schedule Automatic Backups page.

[Warning]Warning

Do not forget to surround the URL in double quotes. If you don't the backup will fail! The reason is that the ampersand is also used to separate multiple commands in a single command line. If you don't use the double quotes at the start and end of the backup URL, your host will think that you tried to run multiple commands.

If you're unsure, check with your host. Sometimes you have to get from them the full path to wget in order for CRON to work, thus turning the above command line to something like:

/usr/bin/wget --max-redirect=10000 "http://www.yoursite.com/index.php?

view=remote&key=YourSecretKey"

Likewise, for Akeeba Backup for WordPress that would be:

/usr/bin/wget --max-redirect=10000 "http://www.yoursite.com/wp-admin/

admin-ajax.php?action=akeebabackup_legacy&key=YourSecretKey"

Contact your host; they usually have a nifty help page for all this stuff. Read also the section on CRON jobs below.

Optionaly, you can also include an extra parameter to the above URL, &profile=profile_id, where profile_id is the numeric ID of the profile you want to use for the backup. If you don't specify this parameter, the default backup profile (ID=1) will be used. In this sense, the aforementioned URL becomes:

/usr/bin/wget --max-redirect=10000 "http://www.yoursite.com/index.php?

view=remote&key=YourSecretKey&profile=profile_id"

Likewise for Akeeba Backup for WordPress that would be

/usr/bin/wget --max-redirect=10000 "http://www.yoursite.com/wp-admin/

admin-ajax.php?action=akeebabackup_legacy&key=YourSecretKey&profile=profile_id"

wget is multi-platform command line utility program which is not included with all operating systems. If your system does not include the wget command, it can be downloaded at this address: http://wget.addictivecode.org/FrequentlyAskedQuestions#download. The wget homepage is here: http://www.gnu.org/software/wget/wget.html. Please note that the option --max-redirect is available on wget version 1.11 and above.

[Important]Important

Using a web browser (Internet Explorer, Google Chrome, ...) or wget version 1.10 and earlier will most probably result into an error message concerning the maximum redirections limit being exceeded. This is not a bug. Most network software will stop dealing with a web site after it has redirected the request more than 20 times. This is a safety feature to avoid consuming network resources on misconfigured web sites which have entered an infinite redirection loop. Akeeba Solo uses redirections creatively, to force the continuation of the backup process without the need for client-side scripting. It is possible, depending on site size, Akeeba Solo configuration and server setup, that it will exceed the limit of 20 redirections while performing a backup operation.

[Warning]Warning

The ampersands above should be written as a single ampersand, not as an HTML entity (&). Failure to do so will result in a 403: Forbidden error message and no backup will occur. This is not a bug, it's the way wget works.

If you have enabled password protection by .htaccess for your Akeeba Solo installation you will need to also supply this common username and password in wget's command line. The correct command line will now look like this:

wget --max-redirect=10000 --user=yourUsername --password=yourPassword

"http://www.yoursite.com/index.php?view=remote&key=YourSecretKey"

(for Akeeba Backup for WordPress replace index.php?view=remote with /wp-admin/admin-ajax.php?action=akeebabackup_legacy)

where yourUsername is the common username and yourPassword is the common password.

Using webcron.org to automate your backups

Assuming that you have already bought some credits on webcron.org, here's how to automate your backup using their service.

First, go to Akeeba Solo's main page and click on the System Configuration button. Find the option titled Enable front-end and remote backup and set it to Yes. Below it, you will find the option named Secret key. Type in a secret key. We strongly recommend using only alphanumeric characters, i.e. 0-9, a-z and A-Z. For the sake of this example, we will assume that you have entered ak33b4s3cRet in that field. We will also assume that your site is accessible through the URL http://www.example.com.

Log in to webcron.org. In the CRON area, click on the New Cron button. Here's what you have to enter at webcron.org's interface:

  • Name of cronjob: anything you like, e.g. "Backup www.example.com"

  • Timeout: 180sec; if the backup doesn't complete, increase it. Most sites will work with a setting of 180 or 600 here. If you have a very big site which takes more than 5 minutes to back itself up, you might consider using the native CRON script (backup.php) instead, as it's much more cost-effective.

  • Url you want to execute: http://www.example.com/index.php?view=remote&key=ak33b4s3cRet

    (for Akeeba Backup for WordPress replace index.php?view=remote with /wp-admin/admin-ajax.php?action=akeebabackup_legacy)

  • Login and Password: Leave them blank, unless you have enabled password protection by .htaccess for your Akeeba Solo installation. In this case you will need to supply this common username and password in these fields.

  • Execution time (the grid below the other settings): Select when you want your CRON job to run

  • Alerts: If you have already set up alert methods in webcron.org's interface, we recommend choosing an alert method here and not checking the "Only on error" so that you always get a notification when the backup CRON job runs.

Now click on Submit and you're all set up!

A PHP alternative to wget

As user DrChalta pointed out in a forum post, there is an alternative to wget, as long as your PHP installation has the cURL extension installed and enabled. For starters, you need to save the following PHP script as backup.php somewhere your host's cron feature can find it. Please note that this is a command-line script and needn't be located in your site's root; it should be preferably located above your site's root, in a non web-accessible directory.

The script below is a modification over DrChalta's original script, taking into account changes made in later versions of our software. In order to configure it for your server, you only have to change the first three lines.

(for Akeeba Backup for WordPress replace index.php?view=remote with /wp-admin/admin-ajax.php?action=akeebabackup_legacy)

<?php
define('SITEURL', 'http://www.example.com'); // Base URL of your site
define('SECRETKEY', 'MySecretKey'); // Your secret key
define('PROFILE',1); // The profile's ID

// ====================== DO NOT MODIFY BELOW THIS LINE ======================
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,
SITEURL.'/index.php?view=remote&key='.
SECRETKEY.'&profile='.PROFILE);
curl_setopt($curl_handle,CURLOPT_FOLLOWLOCATION,TRUE);
curl_setopt($curl_handle,CURLOPT_MAXREDIRS,10000); # Fix by Nicholas
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
    echo "Sorry, the backup didn't work.";
else
    echo $buffer;
?>

Where www.yoursite.com and YourSecretKey should be set up as discussed in the previous section.

[Warning]Warning

The ampersands above should be written as a single ampersand, not as an HTML entity (&amp;). Failure to do so will result in a 403: Forbidden error message and no backup will occur. This is not a bug, it's the way wget and PHP work.

[Note]Note

The script above will NOT work if you have enabled password protection by .htaccess for your Akeeba Solo installation.

In order to call this script with a schedule, you need to put something like this to your crontab (or use your host's CRON feature to set it up):

0 3 * * 6 /usr/local/bin/php /home/USER/backups/backup.php

Where /usr/local/bin/php is the absolute path to your PHP command-line executable and /home/USER/backups/backup.php is the absolute path to the script above.

If you set up your cron schedule with a visual tool (for example, a web interface), the command to execute part is "/usr/local/bin/php /home/USER/backups/backup.php".

Thank you DrChalta for this wonderful tip!

Using the front-end backup in SiteGround and other hosts using cURL instead of wget

As one of our users pointed out in the support forum, finding the correct command to issue for the CRON job is tricky. What he writes applies not only to his host, SiteGround, but many other commercial hosts as well. We'll simply quote our user, bzcoder.

In the CPanel for SiteGround there is a cronjob option, you create a cronjob using that and use:

curl -b /tmp/cookies.txt -c /tmp/cookies.txt -L --max-redirs 1000 -v "<url>"

as your command.

Replace <url> with your backup URL. Make sure to use the URL displayed in the Schedule Automatic Backups page.

Native CRON script

[Tip]Tip

Our users report that they get no joy using this script on GoDaddy hosting, but our alternative script (detailed on the next chapter) works.

If you have access to the command-line version of PHP, Akeeba Solo Professional includes an even better - and faster - way of scheduling your backups. All Akeeba Solo Professional releases include the file cli/backup.php, which can be run from the command-line PHP interface (PHP CLI). In contrast with previous releases, it doesn't require the front-end backup in order to work; it is self-contained, native backup for your sites, even if your web server software is down!

In order to schedule a backup, you will have to use the following command line to your host's CRON interface:

/usr/local/bin/php /home/USER/webroot/cli/backup.php

where /usr/local/bin/php is the path to your PHP CLI executable and /home/USER/webroot is the absolute path to your web site's root. You can get this information from your host.

The backup script accepts three optional parameters:

  • --profile profile_id allows you to select which backup profile you would like to use for the scheduled backup. The profile_id is the numeric profile ID you can see in your Control Panel page.

  • --description "Your description" allows you set a backup description different than the default. Do not forget to enclose your description in double quotes, or this parameter will not work! The description supports backup naming variables, e.g. [SITE], [DATE] and [TIME]. This allows you to use them in conjunction with this parameter to provide flexible backup descriptions.

  • --override "keyname=value" allows you to override profile configuration variables. This parameter can appear an unlimited number of times in the command line. It can be used, for example, to provide the username and password to your cloud storage service in the command line, without having to store it in the backup profile's configuration, therefore never storing it in database and hiding it from other administrators. Please take a look at the "Overriding configuration variables" subsection for more information.

  • --quiet will suppress all output except warnings and error messages. If the backup runs successfully you get no output at all.

The backup.php script will return a different exit code, depending on the backup status. When the backup is successful and without warnings, the exit code will be 0. When the backup completed but with warnings, the exit code will be 1. Finally, if the backup fails, the exit code will be 2. This allows you to check the backup status, for example inside a shell script, for automation purposes.

In order to give some examples, I will assume that your PHP CLI binary is located in /usr/local/bin/php - a common setting among hosts - and that your web site's root is located at /home/johndoe/httpdocs.

  1. Backup with the default profile (ID = 1) and default description:

    usr/local/bin/php /home/johndoe/httpdocs/cli/backup.php
  2. Backup with profile number 2 and default description:

    usr/local/bin/php /home/johndoe/httpdocs/cli/backup.php --profile=2
  3. Backup with the default profile (ID = 1) and a description reading "My automated backup":

    usr/local/bin/php /home/johndoe/httpdocs/cli/backup.php --description="My automated backup"
  4. Backup with profile number 2 and a description reading "My automated backup":

    usr/local/bin/php /home/johndoe/httpdocs/cli/backup.php --profile=2
      --description="My automated backup"

It goes without saying that the line breaks are for readability only. You should not include line breaks in your command line.

Special considerations:

  • All parameters must start with a double dash. If you use a single dash, they will be ignored. We follow the UNIX conventions of command line parameters.

  • Most hosts do not impose a time limit on scripts running from the command-line. If your host does and the limit is less than the required time to backup your site, the backup will fail.

  • This script is not meant to run from a web interface. If your host only provides access to the CGI or FastCGI PHP binaries, backup.php will most likely not work with them. The solution to this issue is tied to the time constraint above. We do try to work around this constraint but it's not possible in all hosts and server configurations.

  • Some servers do not fully support this backup method. The usual symptoms will be a backup which starts but is intermittently or consistently aborted in mid-process without any further error messages and no indication of something going wrong. In such a case, trying running the backup from the back-end of your site will work properly. If you witness similar symptoms please use the Alternative CRON Script, outlined in the next section.

Setting up a CRON job on cPanel

Go to your cPanel main page and choose the CRON Jobs icon from the Advanced pane. In the Add New CRON Job box on the page which loads, enter the following information:

Common Settings

Choose the frequency of your backup, for example once per day.

Command

Enter your backup command. Usually, you have to use something like:

/usr/bin/php-cli /home/myusername/public_html/cli/backup.php --profile=YourProfileID

for Akeeba Solo, or

/usr/bin/php-cli /home/myusername/public_html/wp-content/plugins/akeebabackupwp/app/cli/backup.php --profile=YourProfileID

for Akeeba Backup for WordPress, where myusername is your account's user name (most probably the same you use to login to cPanel) and YourProfileID is the numeric profile number you want to use for your backup job. Do note the path for the PHP command line executable: /usr/bin/php5-cli. This is the default location of the correct executable file for cPanel 11 and later. Your host may use a different path to the executable. If the command never runs, ask them. We can't help you with that; only those who have set up the server know the changes they have made to the default setup.

Finally, click the Add New Cron Job button to activate the CRON job.

Overriding configuration variables

The Native CRON Script allows you to override or supply missing configuration variables in the command line. This is especially useful for security reasons. One security issue with the cloud storage service integration is that other administrators can peek at Akeeba Solo's configuration and read the username, password or API keys used to access the cloud storage service. You can, however, leave these fields blank in the configuration and supply their values in the command line.

Overriding a configuration variable requires knowing its key name. The key names are represented in dot-format, i.e. engine.postproc.s3.accesskey for Amazon S3's access key. Determining the key name is quite easy, as they are stored in INI files throughout the component's back-end. The first location you should look at is vendor/akeeba/engine/engine/core, where you will find four INI files with general settings. Inside the vendor/akeeba/engine/engine/engines and vendor/akeeba/engine/engine/plugins/engines directories and their subdirectories you will find one INI file per engine.

In order to save you from trouble, here are the most useful key names for providing cloud storage engine credentials. The names are designed to be self-explanatory.

Amazon S3
  • engine.postproc.s3.accesskey

  • engine.postproc.s3.secretkey

RackSpace CloudFiles
  • engine.postproc.cloudfiles.username

  • engine.postproc.cloudfiles.apikey

Dropbox
  • engine.postproc.dropbox.token

  • engine.postproc.dropbox.token_secret

Microsoft Windows Azure BLOB Storage
  • engine.postproc.azure.account

  • engine.postproc.azure.key

Remote FTP server
  • engine.postproc.ftp.host

  • engine.postproc.ftp.port

  • engine.postproc.ftp.user

  • engine.postproc.ftp.pass

Applying them on the command line is easy. Take this command line as an example:

usr/local/bin/php /home/johndoe/httpdocs/cli/backup.php
--profile=2 --description="My automated backup"
--override="engine.postproc.s3.accesskey=ABCDEF"
--override="engine.postproc.s3.secretkey=1234567890abcdefgh"

In this case, we are telling the backup script to use the backup Profile with ID=2, give the backup description of "My automated backup" and then supply the S3 access and secret keys.

[Important]Important

The values of the override parameters must be enclosed in double or single quotes (depends on your Operating System), otherwise the operating system will not pass them back to the backup.php script.

[Important]Important

Your script MUST NOT include the line breaks in the previous example. The line breaks are there only for typesetting purposes.

Finally, it should be noted that you can use the command-line override feature to do more tricky configuration overrides, for example turning off the archive splitting or using a different backup output directory to enhance your security. If it's something you can do in the Configuration page of the component, you can also do it using command line overrides.

Alternative CRON script

[Important]Important

This script will NOT work if you have enabled password protection by .htaccess for your Akeeba Solo installation.

On some hosts it is impossible to use the native CRON script outlined in the previous section. On such hosts the CRON script will get aborted if it is using too much CPU time, or if the system load exceeds a value predefined by your host company. In order to accomodate for these hosts, Akeeba Solo includes an alternative CRON script. The alternative CRON script performs the backup by using the front-end backup feature of Akeeba Solo. The alternative CRON script must be run from the command-line PHP interface (PHP CLI).

In order to schedule a backup, you will have to use the following command line to your host's CRON interface:

/usr/local/bin/php /home/USER/webroot/cli/altbackup.php

where /usr/local/bin/php is the path to your PHP CLI executable and /home/USER/webroot is the absolute path to your web site's root. You can get this information from your host.

The backup script accepts the following optional parameters:

  • --profile=profile_id allows you to select which backup profile you would like to use for the scheduled backup. The profile_id is the numeric profile ID you can see in the main page.

  • --no-verify Only applies to HTTPS connections. If you have a plain HTTP site you can ignore this setting. Since Akeeba Backup for WordPress and Akeeba Solo 2.3.3 this script will check that the SSL certificate presented by the server is issued by a known, trusted Certification Authority and that the domain name included in the certificate matches the domain name of your site. If you want to disable this verification, e.g. because you're using a self-signed certificate or a certification authority internal to your organization you need to pass the --no-verify option. This will disable the verification, emulating the way this script worked in Akeeba Backup for WordPress and Akeeba Solo 2.3.2 and earlier.

In order to give some examples, we will assume that your PHP CLI binary is located in /usr/local/bin/php - a common setting among hosts - and that your web site's root is located at /home/johndoe/httpdocs.

  1. Backup with the default profile (ID = 1)

    usr/local/bin/php /home/johndoe/httpdocs/cli/altbackup.php
  2. Backup with profile number 2

    usr/local/bin/php /home/johndoe/httpdocs/cli/altbackup.php --profile=2

It goes without saying that the line breaks are for readability only. You should not include line breaks in your command line.

Special considerations:

  • Most hosts do not impose a time limit on scripts running from the command-line. If your host does and the limit is less than the required time to backup your site, the backup will fail.

  • This script is not meant to run from a web interface. If your host only provides access to the CGI or FastCGI PHP binaries, altbackup.php will probably not work with them.

  • You must enable the front-end backup feature of your Akeeba Solo Professional instalaltion and assign a "secret key" for it. This is possible by going to the Akeeba Solo's main page and clicking on the System Configuration button. You will find the front-end backup options in the Remote API tab.

  • Before using the alternative CRON script for the first time, you must visit the Akeeba Solo's main page at least once. Since the command-line version of PHP used to run the backup is oblivious to the domain name used by your Akeeba Solo installation, we have to cache this information. Caching of this information occurs as soon as you visit the main page. The host name is absolutely required in order for the script to be able to access your Akeeba Solo installation's front-end backup feature.

  • Your host must support one of the three methods used by the helper script to access your front-end backup URL:

    1. The PHP cURL module.

    2. The fsockopen() method

    3. The fopen() URL wrappers

    If none of these methods is available, the backup will fail.

  • Your host may have a firewall setup which doesn't allow the CRON script to access the front-end backup URL. In such a case, the backup will consistently fail without a new log file being produced and without a backup entry being written to the database. You will have to contact your host so that they can allow the script to access the front-end backup URL. Do note that despite the alternative CRON script and your site running on the same server, the firewall restriction might still be in place. This is counter-intuitive, but we've seen this happening on man hosts.

If you are seeking assistance in our forums regarding a failed CRON job, please indicate if and which of these steps you have already tried. Not doing so will hinder our ability to help you in a timely manner.

Setting up a CRON job on cPanel

Go to your cPanel main page and choose the CRON Jobs icon from the Advanced pane. In the Add New CRON Job box on the page which loads, enter the following information:

Common Settings

Choose the frequency of your backup, for example once per day.

Command

Enter your backup command. Usually, you have to use something like:

/usr/bin/php-cli /home/myusername/public_html/cli/altbackup.php --profile=YourProfileID

for Akeeba Solo, or

/usr/bin/php-cli /home/myusername/public_html/wp-content/plugins/akeebabackupwp/app/cli/altbackup.php --profile=YourProfileID

for Akeeba Backup for WordPress, where myusername is your account's user name (most probably the same you use to login to cPanel) and YourProfileID is the numeric profile number you want to use for your backup job. Do note the path for the PHP command line executable: /usr/bin/php5-cli. This is the default location of the correct executable file for cPanel 11 and later. Your host may use a different path to the executable. If the command never runs, ask them. We can't help you with that; only those who have set up the server know the changes they have made to the default setup.

Finally, click the Add New Cron Job button to activate the CRON job.

Special notes for GoDaddy

According to our users who have tried this, this laternative script does work with GoDaddy. The command line you have to use is:

/usr/local/php5/bin/php "$HOME/html/cli/altbackup.php" --profile=YourProfileID

where YourProfileID is the numeric profile number you want to use for your backup job.

The PHP executable we are using is the CLI rather than the default CGI. This is important; if you use the CGI executable then the script will not run. Don't forget to enable frontend backup and insert your secret word. To enable frontend backup go to Akeeba Solo under components, select configuration, select options from the navigation, then select the front-end backup tab to enable the settings.

If the backup completes successfully but the backup appears as "Failed" in the Manage Backups page, you'll have to apply a workaround. Go to Akeeba Solo and select your backup profile from the drop-down list. Then click on the Configuration button. In the configuration page check the Use database storage for temporary data option.