The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change default backup destination?

Discussion in 'Data Protection' started by MyPC8MyBrain, Apr 29, 2017.

Tags:
  1. MyPC8MyBrain

    MyPC8MyBrain Member

    Joined:
    Apr 29, 2017
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Website Owner
    hello CPanel community :)
    i am trying to change default full backup destination of dofullbackup.php,
    i am running this basic script in my cron job,
    whenever i set ftp true the backup will fail,
    is there a way to use lftp with this script?
    or ideally just set a different local folder output then root dir instead of moving a local file via ftp locally?

    TIA
    Chris

    PHP:
    <?php
    $cpaneluser 
    'user'// cPanel username
    $cpaneluserpass 'pass'// cPanel password
    $theme 'paper_lantern'// Must match current selected cPanel theme ('paper_lantern' in the majority of cases, 'x3' is possible as well)
    $ftp true// If it's false the backup will be stored in user's home directory, otherwise it will be uploaded via FTP to some custom location
    $ftpserver 'serverX.web-hosting.com'// Must be localhost for current server or custom hostname for remote FTP upload
    $ftpusername 'user'// cPanel/SFTP username. Should be the same as cPanel username for local upload or custom for remote upload
    $ftppassword 'pass'// cPanel/SFTP password. Should be the same as cPanel password for local upload or custom for remote upload
    $ftpport '21098'// SFTP port. Should be 21 in most cases.
    $ftpdirectory '/home/user/backups'// Directory on FTP server to store backups. MUST EXIST BEFORE BACKUP OR BACKUP PROCESS WILL FAIL
    // Do not edit below this line
    $domain 'localhost';
    $secure true;
    $auth base64_encode($cpaneluser ":" $cpaneluserpass);
    if (
    $secure) {
        
    $url "ssl://" $domain;
        
    $port 2083;
        } else { 
        
    $url $domain
        
    $port 2082;
    }
    $socket fsockopen('localhost'2082);
    if (!
    $socket) { 
        exit(
    "Failed to open socket connection.");
    }
    if (
    $ftp) {
    $params "dest=scp&server=$ftpserver&user=$ftpusername&pass=$ftppassword&port=$ftpport&rdir=$ftpdirectory&submit=Generate Backup";
    } else {
       
    $params "submit=Generate Backup";
    }
    fputs($socket"POST /frontend/" $theme "/backup/dofullbackup.html?" $params " HTTP/1.0\r\n");
    fputs($socket"Host: $domain\r\n");
    fputs($socket"Authorization: Basic $auth\r\n");
    fputs($socket"Connection: Close\r\n");
    fputs($socket"\r\n");
    while (!
    feof($socket)) {
       
    $response fgets($socket4096);
    //     echo $response; //uncomment this line for debugging
    }
    fclose($socket);
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,037
    Likes Received:
    1,278
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Rather than using the custom PHP script, try using the command referenced on the feature request for this functionality when setting up a cron job:

    Automatic Backup of single cPanel account

    Thank you.
     
    MyPC8MyBrain likes this.
  3. MyPC8MyBrain

    MyPC8MyBrain Member

    Joined:
    Apr 29, 2017
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Website Owner
    Thank you very much Michael,
    the suggested solution above doesn't seem to work in my case :(
    i am getting "cpapi1: command not found" (CentOs 6.9 shared hosting)
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,037
    Likes Received:
    1,278
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    We introduced this functionality in cPanel & WHM version 56. Could you verify the system you are testing this on is using that version of cPanel or newer? If not, you may want to reach out to your web hosting provider to inquire about updating cPanel to a newer version.

    Thank you.
     
    MyPC8MyBrain likes this.
  5. MyPC8MyBrain

    MyPC8MyBrain Member

    Joined:
    Apr 29, 2017
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Website Owner
    Thank you Michael,
    at this point im unable to pull up CPanel version from a shared environment,
    i tried to run cat /usr/local/cpanel/version & usr/local/cpanel/cpanel -V through ssh but im getting "No such file or directory"
    i don't have access to the whm portion where i used to see it listed at the top before,
    i will check with godaddy why im unable to perform this atm,

    TIA
    Chris
     
    cPanelMichael likes this.
Loading...

Share This Page