{"id":325,"date":"2023-07-16T15:59:43","date_gmt":"2023-07-16T15:59:43","guid":{"rendered":"https:\/\/www.ehcp.net\/?p=325"},"modified":"2023-08-13T20:38:08","modified_gmt":"2023-08-13T20:38:08","slug":"about-backup","status":"publish","type":"post","link":"https:\/\/www.ehcp.net\/?p=325","title":{"rendered":"About Backup"},"content":{"rendered":"\n<p>Hello! Is great that backup can be made from panel!<br>I have 3 problems about backup.<\/p>\n\n\n\n<p>1. Can this backup run automaticaly once on a week?<br>2. How can I copy that file on another computer, in case the server dies&#8230; Can it be copied automaticaly?<br>3. Why normal users cannot backup their sites? Only the admin can do it.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>There is a backup function in Ehcp gui now, but not tested much in latest versions of Ehcp+Ubuntu<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Question:<\/p>\n\n\n\n<p>I&#8217;ve been jusing ehcp now for a half year. I&#8217;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&#8217;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?<\/p>\n\n\n\n<p>Answer:<\/p>\n\n\n\n<p>Hi,<br>congratulations for your good experience with ehcp.<br>I just wrote a small php program that does what you want,<br>copy following code in a php file, save, then, you may run that file in a cron job,<br>if you have any further difficulty\/help, let me know..<\/p>\n\n\n\n<p><code><br>#!\/usr\/bin\/env php<br>&lt;?php<\/code><\/p>\n\n\n\n<p>include_once(&#8220;config\/dbutil.php&#8221;);<br>include_once(&#8220;config\/adodb\/adodb.inc.php&#8221;); # adodb database abstraction layer.. hope database abstracted&#8230;<br>include_once(&#8220;classapp.php&#8221;); # real application class<\/p>\n\n\n\n<p>$app = new Application();<br>$app-&gt;requirePassword=false;<br>$app-&gt;initialize();<\/p>\n\n\n\n<p>$backupname=&#8217;mybackup&#8217;.date(&#8216;YmdHmi&#8217;);<br>$whattobackup=&#8221;files,mysql&#8221;; # you may also include ehcp&#8217;s files here..<\/p>\n\n\n\n<p>$app-&gt;daemonBackup(&#8221;,$backupname,$whattobackup);<\/p>\n\n\n\n<p>echo &#8220;hope finished&#8230; :)&#8221;;<br>?&gt;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>write that code in a php file, for ex ehcpbackup.php<\/p>\n\n\n\n<p>then on console,<br>chmod a+x ehcpbackup.php<\/p>\n\n\n\n<p>then,<br>crontab -e<\/p>\n\n\n\n<p>then write\/add following line into crontab<br>*\/60 * * * * \/pathto\/ehcpbackup.php<\/p>\n\n\n\n<p>replace path with real one.<br>thats all.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>if i use the backup-script as it is in ver.0.29.13<br>it is creating the backupfile but with 0 content(empty.<\/p>\n\n\n\n<p>something i understand wrong?<\/p>\n\n\n\n<p>do i have to change this ?:<br>$whattobackup=&#8221;files,mysql&#8221;; # you may also include ehcp&#8217;s files here..<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>found the typo. here is the script how i use it.<\/p>\n\n\n\n<p>#!\/usr\/bin\/env php<br>&lt;?php<\/p>\n\n\n\n<p>include_once(&#8220;\/var\/www\/vhosts\/ehcp\/config\/dbutil.php&#8221;);.<br>include_once(&#8220;\/var\/www\/vhosts\/ehcp\/config\/adodb\/adodb.inc.php&#8221;); # adodb database abstraction layer.. hope database abstracted&#8230;<br>include_once(&#8220;\/var\/www\/vhosts\/ehcp\/classapp.php&#8221;); # real application class<\/p>\n\n\n\n<p>$app = new Application();<br>$app-&gt;requirePassword=false;<br>$app-&gt;initialize();<\/p>\n\n\n\n<p>$backupname=&#8217;mybackup&#8217;.date(&#8216;Y-m-d-H-m-i&#8217;);<br>$whattobackup=&#8221;-files,-mysql&#8221;; # you may also include ehcp&#8217;s files here..<\/p>\n\n\n\n<p>$app-&gt;daemonBackup(&#8221;,$backupname,$whattobackup);<\/p>\n\n\n\n<p>echo &#8220;hope finished&#8230; :)&#8221;;<br>?&gt;<\/p>\n\n\n\n<p>most important is:<br>$whattobackup=&#8221;-files,-mysql&#8221;; \/\/the &#8220;-&#8221; was not set in your script!!!<\/p>\n\n\n\n<p>and&#8230;.happy again!<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>you are absolutely right. thankyou for this bug report.<br>i will fix it here also, in ehcp sources that is downloaded by everyone.<br>you learned php\/ehcp coding now \ud83d\ude42<\/p>\n\n\n\n<p>how did you find it, i mean php coding style of ehcp ? almost anything in classapp.php, a single class ?<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>yes&#8230;just searched for the definition. i use ehcp for i think close to 3 years now and i\u00b4ve read all the code so i know it was in classapp.<\/p>\n\n\n\n<p>i can read and understand coding but never have learned coding by my self and now as a 53 years old farth it\u00b4s hard to find the time to do it.<br>but you do it in a smart way!!!<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; Can it be copied automaticaly?3. Why normal users cannot backup their sites? Only the admin can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":327,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/posts\/325"}],"collection":[{"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=325"}],"version-history":[{"count":1,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/posts\/325\/revisions"}],"predecessor-version":[{"id":328,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/posts\/325\/revisions\/328"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=\/wp\/v2\/media\/327"}],"wp:attachment":[{"href":"https:\/\/www.ehcp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ehcp.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}