The Frontend backup function is intended to provide the capability to perform an unattended, timed backup of your site.
![]() | Tip |
---|---|
Since JoomlaPack 2.0 Stable there is a more efficient way to remotely initiate a site backup. You can use our new JoomlaPack Remote utility for Windows (part of the JoomlaPack Native Tools distribution) to backup your sites right from your desktop, automatically downloading the backup files as well. However, it does not allow for backup scheduling with the same flexibility as cron used with the front-end backup feature does. |
The script performs one backup step and sends an 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 302 headers pointing to itself, the web browser thinks that the web server has had some sort of malfunction and stop bothering with the page. It might 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 if you use the Slow algorithm or have a large web site.
Command line utilities will give up on a page after it has been redirected a number of times. For example, wget gives up after 20 redirects, curl after 50 redirects. Since JoomlaPack redirects once for every step, it is advisable to configure your command line utility with a large number of redirects; I believe 1000 will do for 99,9% of sites.
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. 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=1000
"http://www.yoursite.com
/index2.php?option=com_joomlapack&
view=backup&key=YourSecretKey
&format=raw"
Of course, the line breaks are included for formatting clarity only. You should not have a line break in your command line!
![]() | Important |
---|---|
Do not miss the --max-redirect=1000 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. |
![]() | Warning |
---|---|
Do not forget the double quotation marks which surround the URL. Otherwise the ampersands and other special characters will be interpreted by your shell and cause the backup to fail. |
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=1000
"http://www.yoursite.com
/index2.php?option=com_joomlapack&
view=backup&key=YourSecretKey
&format=raw"
Contact your host; they usually have a nifty help page for all this stuff.
Optionaly, you can also include an extra parameter to the above URL,
&id=
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=1000
"http://www.yoursite.com
/index2.php?option=com_joomlapack&
view=backup&key=YourSecretKey
&format=raw&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. At the time of this
writing this particular version was not available for the Windows
™operating system.
![]() | Important |
---|---|
Using a web browser (Internet Explorer, Firefox, ...) or
|
As user DrChalta pointed out in this support forum post, there is an alternative to wget, as long as your PHP installation has the cURL extension installed and enabled. For sterters, you need to save the following PHP script as bacup.php somewhere your cron daemon 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 preferrably located above your site's root, in a non-web-accessible directory.
<?php ///////////////////// //Initialize cURL // //////////////////// $curl_handle=curl_init(); ///////////////////// //Set cURL Options// //////////////////// //The URL to call curl_setopt($curl_handle,CURLOPT_URL, 'http://www.yoursite.com
/index2.php?option=com_joomlapack&'. 'view=backup&key=YourSecretKey
&format=raw'); //TRUE to follow any "Location: " header that the server sends as part of //the HTTP header (note this is recursive, PHP will follow as many //"Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set). curl_setopt($curl_handle,CURLOPT_FOLLOWLOCATION,TRUE); //TRUE to return the transfer as a string of the return value of //curl_exec() instead of outputting it out directly. curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); ////////////////// //Open the Page // ////////////////// $buffer = curl_exec($curl_handle); curl_close($curl_handle); ////////////////// //Error Message // ////////////////// if (empty($buffer)) { print "Sorry, the backup didn't work.<p>"; } else { print $buffer; } ?>
Where www.yoursite.com
and
YourSecretKey
should be set up as discussed in
the previous section.
In order to call this script with a schedule, you need to put something like this to your crontab:
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!