Results 1 to 6 of 6

Thread: Automatic cPanel backup with cron and PHP

  1. #1
    Join Date
    Apr 2010
    Posts
    84

    Automatic cPanel backup with cron and PHP

    I want to do a full backup of my site before making me hack. I make regular backups of my databases (manually or with a plugin like WP-DbManager) and my files but I recently was looking to automate things and I found. In fact, I am fortunate to have Cpanel as a management tool on my accommodation and I came across this section which the author proposes a PHP script to automate the backup using Cron. Please help for step. Thanks.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Automatic cPanel backup with cron and PHP

    You need to go through the tab "Backup" and manually click to launch such a project but with this script, the backup is done when I want and I am more notified by email. PHP script to allow periodic cPanel backups Automatically, OPTIONALLY to a remote FTP server.This script contains passwords. KEEP ACCESS TO THIS FILE SECURE! (Place it in your home dir, not / www /)

    PHP Code:
    // Info required for cPanel access
    Cpus "Username"; / / Username Used to login to CPanel
    Cppass "Password"; / / Password Used to login to CPanel
    <span> $ Domain "<A href ="http:/// / Example.com "> example.com </ a>" / / Domain name WHERE IS CPanel run </ span>
    Skin "X"; / / Set to cPanel skin you use (script will not work if it does not match). Most people run the default x theme
    / / Info required for FTP host
    Ftpuser "Ftpusername"; / / Username for FTP account
    Ftppass "Ftppassword"; / / Password for FTP account
    <span> $ Ftphost "<A href ="http:/// / Ftp.example.com "> ftp.example.com </ a>"; / / Full hostname or IP address for FTP host </ span>
    Ftpmode "Ftp"; / / FTP mode ("ftp" for active"passiveftp" for passive)
    / / 
    Notification information
    <span> $ Notifyemail "You @ <a href ="http:/// / Example.com "> example.com </ a>"; / / Email address to send results </ span>
    / / Secure or non-secure mode
    Secure 0; / / Set to 1 for SSL (requires SSL support), Otherwise Will use standard HTTP
    / / Set to a new serie web page APPEAR result in your cron log
    Debug 0;
    / / *********** 
    NO CONFIGURATION ITEMS BELOW THIS LINE *********

    if ($ 
    Secure) {
    Url "ssl: / /".$ Domain;
    Port 2083;
    } else {
    Url = $ Domain;
    Port 2082;
    }
     
    Socket fsockopen($ Url,$ Port);
    if (!$ 
    Socket) { echo "Failed to open socket connection ... Bailing out \ n"; exit; }
     
    / / 
    Encode authentication string
    Authstr = $ Cpus.":".$ Cppass;
    Pass base64_encode($ Authstr);

    Params "Dest = $ ftpmode &amp; amp; notifyemail $ email = &amp; amp; ftphost $ server = &amp; amp; user = $ ftpuser &amp; amp; ftppass $ pass = &amp; amp; submit = Generate Backup ";
    / / 
    Make POST to cPanel
    fputs
    ($ Socket,"POST / frontend /".$ Skin."/ Backup / dofullbackup.html?".$ Params."HTTP/1.0 \ r \ n");
    fputs($ Socket,"Host: $ domain \ r \ n");
    fputs($ Socket,"Authorization: Basic $ pass \ r \ n");
    fputs($ Socket,"Connection: Close \ r \ n");
    fputs($ Socket,"\ R \ n");
     
    / / 
    Grab response Even If We Do not Do Anything With It.
    while (!
    feof($ Socket)) {
    Response fgets($ Socket,4096);
    if ($ 
    Debug) echo $ Response;
    }
    fclose ($ Socket);
    ?> 

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Automatic cPanel backup with cron and PHP

    You need to create a new cron job (cron job) like this:
    * go to "Cron Spot"
    * choose the "advanced (unix) mode"
    * indicate the times and dates must be made this script:
    For example, every night at 2:15 am:
    February 15 * * * / usr / local / bin / php / home /youraccount/ Fullbackup.php
    or every Sunday at 2:15 am:
    February 15 * * 1 / usr / local / bin / php / home /youraccount/ Fullbackup.php

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Automatic cPanel backup with cron and PHP

    Its up to your pure ftp. After some research, I have indeed chosen pure-ftp to its reputation for safety (what it says ^ ^) and especially because it will allow me to do what I want fairly simple (as you'll be able to report). I am much inspired tutorial available here (I recommend you also coagulated, site is excellent for those who want "administer" his machine : ) As usual, the installation is done by the command:

    Code:
    apt-get install pure-ftpd
    Configuring pure-ftp is special, in fact it hinges on the command line and much of the configuration is done by the presence or absence of a single file configuration option (I guess it avoids a large file to parse configuration ^_~).

  5. #5
    Join Date
    Feb 2010
    Posts
    137

    Re: Automatic cPanel backup with cron and PHP

    The backup and restore effective and complete in porated all! Have you lost data following an attack of a virus, because a computer problem, a natural disaster (flood, fire) or theft ... ? To protect them, only one answer: back up! Save Your Data is compatible with Windows Vista (TM). An Internet connection is only necessary to update the software. Strengths: The backup will become for you a breeze and allow you to save, restore and protect all your data: photos, music, videos, contacts, emails, bookmarks, files, folders ... without even thinking. A mixture of Simplicity and Power! Automatic backup in real time! Recognition of the work environment! 3 assistants at your disposal.

  6. #6
    Join Date
    Feb 2010
    Posts
    131

    Re: Automatic cPanel backup with cron and PHP

    Elearly, although three quarters of clients want the panel is already configured when it arrives (data ready) etc..To be in the process of comparing cPanel and Plesk on two different servers, I can not at this point, asserting that Plesk is easier than cPanel. This is promising, but a panel to equal server configuration, Plesk is significantly slower to use than cPanel and also more complicated. In terms of referrals, cPanel is much more powerful.

Similar Threads

  1. Automatic Shutdown after Windows 7 Backup
    By Revati in forum Windows Software
    Replies: 5
    Last Post: 10-09-2010, 05:57 AM
  2. Backup only configuration data in cPanel
    By Character in forum Software Development
    Replies: 5
    Last Post: 18-06-2010, 04:10 AM
  3. Automatic backup online
    By Zoan in forum Technology & Internet
    Replies: 5
    Last Post: 16-02-2010, 05:38 PM
  4. Windows 7 Automatic Backup
    By Justin23 in forum Operating Systems
    Replies: 4
    Last Post: 25-12-2009, 04:51 PM
  5. Restore Full Backup in cPanel
    By dalsandhu in forum Networking & Security
    Replies: 3
    Last Post: 21-05-2009, 07:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,719,051,311.58953 seconds with 17 queries