Automatic backup is this possible

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?

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

include_once("config/adodb/"); # adodb database abstraction layer.. hope database abstracted...
include_once("classapp.php"); # real application class

$app = new Application();

$whattobackup="files,mysql"; # you may also include ehcp's files here..


echo "hope finished... :)";

did this solve your need ?

Sorry for the late reaction, I was very busy last week. Thank you for your fast reaction, this is what i was searching for. Now I go try to put this in crontabs. On this moment I don't now how but I search for it.

Thank you!

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

then on console,
chmod a+x ehcpbackup.php

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..

make sur your ehcp daemon is running normally, check using
ps aux | grep php

can you please send ehcp.log changes while you do backup ?
tail -f /var/log/ehcp.log

ps aux | grep php
root 3498 0.0 2.1 192340 22224 ? S 06:12 0:03 php index.php daemon
root 9174 0.0 0.0 3876 588 pts/1 S+ 21:50 0:00 grep php

the ehcp.log just shows the daemon loop numbers nothing else

this is the output from the backup:
Backup starting..: dirname:/var/backup/mybackup20100511210552, filename:mybackup20100511210552
executing command: mkdir -p /var/backup/mybackup20100511210552
(escapedcmd: mkdir -p /var/backup/mybackup20100511210552)

pwd is:/var/backup/mybackup20100511210552
total 0

pwd is:/var/backup/mybackup20100511210552
total 0

executing command: tar -zcvf mybackup20100511210552.tgz mybackup20100511210552
(escapedcmd: tar -zcvf mybackup20100511210552.tgz mybackup20100511210552)

pwd is:/var/backup
total 3015708
-rw-r--r-- 1 root root 1542514850 May 11 18:53 backup2010-05-11_06-41-25.tgz
-rw-r--r-- 1 root root 1542520285 May 11 09:55 backup2010-05-11_09-44-34.tgz
-rw-r--r-- 1 root root 122 May 11 18:35 mybackup20100511180535.tgz
-rw-r--r-- 1 root root 125 May 11 18:36 mybackup20100511180536.tgz
-rw-r--r-- 1 root root 125 May 11 18:39 mybackup20100511180539.tgz
-rw-r--r-- 1 root root 124 May 11 21:48 mybackup20100511210548.tgz
drwxr-xr-x 2 root root 4096 May 11 21:52 mybackup20100511210552
-rw-r--r-- 1 root root 122 May 11 21:52 mybackup20100511210552.tgz

executing command: rm -rvf mybackup20100511210552
(escapedcmd: rm -rvf mybackup20100511210552)
removed directory: `mybackup20100511210552'
finished backups..waiting for 5 sec to let you check.hope finished... :)

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

#!/usr/bin/env php

include_once("/var/www/vhosts/ehcp/config/adodb/"); # adodb database abstraction layer.. hope database abstracted...
include_once("/var/www/vhosts/ehcp/classapp.php"); # real application class

$app = new Application();

$whattobackup="-files,-mysql"; # you may also include ehcp's files here..


echo "hope finished... :)";

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

and....happy again!

maybe "bzip" instaed of "tar" would be safe some recources?

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!!!

Now when the backup is finished I get this error

executing command: tar -zcvf mybackup20090306130357.tgz mybackup20090306130357
tar: mybackup20090306130357.tgz: Cannot open: Permission denied
tar: Error is not recoverable: exiting now
tar: mybackup20090306130357: Cannot stat: No such file or directory
tar: mybackup20090306130357.tgz: Cannot write: Broken pipe
tar: Error is not recoverable: exiting now

Warning: filesize(): stat failed for mybackup20090306130357.tgz in /var/www/vhosts/ehcp/classapp.php on line 1526

pwd is:/var/backup
total 229352
-rw-r--r-- 1 root root 14897637 2009-02-05 21:50 backup2009-02-05_09-49-41.tgz
-rw-r--r-- 1 root root 102399486 2009-02-07 19:17 backup2009-02-07_07-16-12.tgz

executing command: rm -rvf mybackup20090306130357
finished backups..waiting for 5 sec to let you check.hope finished... :)Press ENTER to continue and close this window.

What is this can you help me

normally, ehcp daemon does backup.
if you see this error while you do: tail-f /var/log/ehcp.log

then, your ehcp daemon does not run as root user.
make sure that your ehcp daemon is running as root.

go to console
sudo /etc/init.d/ehcp restart

then repeat/retry backup

if you do backup/restore from cron jobs,
then, you should put your cron in cron of root.

Now I get this back

administrator@webserver:~$ tail -f /var/log/ehcp.log

ehcp V.0.25- Daemon loop number:291
-----------daemon suspended for 10 sec ---------
trying re-connecting to mysql db..
reconnect successfull.

Is this good?
Does he run as root?

i cannot understand from that.
to understand:
ps aux | grep index | grep root

if you see like:
root@yenisunucu:~# ps aux | grep index | grep root
root 9411 0.0 0.6 35020 11688 ? S 19:37 0:00 php index.php daemon

then it is root
if you dont see "php index.php daemon" then, it is not..

I get back this

root 5703 0.0 1.2 27288 12332 ? S 16:09 0:00 php index.php daemon

Then it is root

What is wrong then

run this on console:
/etc/init.d/apparmor stop

then retry operation
if apparmor is loaded, then you cannot write to some files even if you are root...
i hope this helps..if not, let me in by ssh

For the new versions of ehcp where the ehcp config files are under /var/www/new

you have to edit the backup script accordingly: