About Backup

Hello! Is great that backup can be made from panel!
I have 3 problems about backup.

1. Can this backup run automaticaly once on a week?
2. How can I copy that file on another computer, in case the server dies… Can it be copied automaticaly?
3. Why normal users cannot backup their sites? Only the admin can do it.


There is a backup function in Ehcp gui now, but not tested much in latest versions of Ehcp+Ubuntu


Question:

I’ve been jusing ehcp now for a half year. I’m very happy with this control panel, the control panel can do anything what you expect of a paid control panel like cpanel, plesk. Three days ago I have installed version 0.29. It’s working fine. But I was wondering if it is possible to make a automatic backup. Now you can only backup by hand. Can I do this with crontabs? So yes, what command must I use? Or is this an idea for a next version?

Answer:

Hi,
congratulations for your good experience with ehcp.
I just wrote a small php program that does what you want,
copy following code in a php file, save, then, you may run that file in a cron job,
if you have any further difficulty/help, let me know..


#!/usr/bin/env php
<?php

include_once(“config/dbutil.php”);
include_once(“config/adodb/adodb.inc.php”); # adodb database abstraction layer.. hope database abstracted…
include_once(“classapp.php”); # real application class

$app = new Application();
$app->requirePassword=false;
$app->initialize();

$backupname=’mybackup’.date(‘YmdHmi’);
$whattobackup=”files,mysql”; # you may also include ehcp’s files here..

$app->daemonBackup(”,$backupname,$whattobackup);

echo “hope finished… :)”;
?>


write that code in a php file, for ex ehcpbackup.php

then on console,
chmod a+x ehcpbackup.php

then,
crontab -e

then write/add following line into crontab
*/60 * * * * /pathto/ehcpbackup.php

replace path with real one.
thats all.


if i use the backup-script as it is in ver.0.29.13
it is creating the backupfile but with 0 content(empty.

something i understand wrong?

do i have to change this ?:
$whattobackup=”files,mysql”; # you may also include ehcp’s files here..


found the typo. here is the script how i use it.

#!/usr/bin/env php
<?php

include_once(“/var/www/vhosts/ehcp/config/dbutil.php”);.
include_once(“/var/www/vhosts/ehcp/config/adodb/adodb.inc.php”); # adodb database abstraction layer.. hope database abstracted…
include_once(“/var/www/vhosts/ehcp/classapp.php”); # real application class

$app = new Application();
$app->requirePassword=false;
$app->initialize();

$backupname=’mybackup’.date(‘Y-m-d-H-m-i’);
$whattobackup=”-files,-mysql”; # you may also include ehcp’s files here..

$app->daemonBackup(”,$backupname,$whattobackup);

echo “hope finished… :)”;
?>

most important is:
$whattobackup=”-files,-mysql”; //the “-” was not set in your script!!!

and….happy again!


you are absolutely right. thankyou for this bug report.
i will fix it here also, in ehcp sources that is downloaded by everyone.
you learned php/ehcp coding now 🙂

how did you find it, i mean php coding style of ehcp ? almost anything in classapp.php, a single class ?


yes…just searched for the definition. i use ehcp for i think close to 3 years now and i´ve read all the code so i know it was in classapp.

i can read and understand coding but never have learned coding by my self and now as a 53 years old farth it´s hard to find the time to do it.
but you do it in a smart way!!!