Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    CJL
    CJL is offline
    Member
    Join Date
    Jun 2009
    Posts
    9

    Default Auto Backup Script

    Hi,

    I am sure a number of people out there use Justin Cooks backup up cron script, my question is am getting an email sent me to me once cpanel tries to run the cron job and I am not sure what it means. I am guess it means it cant access the ftp that I wont it to send the backup to, but could someone clarify this please.

    The email response from cron contains the following;
    /bin/sh: /home/username/public_html/sender.php: Permission denied


    Below is the script that I am using, is it correct? it was quiet straight forward so I assume it is;

    PHP Code:
    <?php

    // 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/)

    // ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

    // Info required for cPanel access
    $cpuser "******"// Username used to login to CPanel
    $cppass "******"// Password used to login to CPanel
    $domain "domain.com.au"// Domain name where CPanel is run
    $skin "x"// Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme

    // Info required for FTP host
    $ftpuser "******"// Username for FTP account
    $ftppass "******"// Password for FTP account
    $ftphost "ftp.domain.com.au"// Full hostname or IP address for FTP host
    $ftpmode "ftp"// FTP mode ("ftp" for active, "passiveftp" for passive)

    // Notification information
    $notifyemail "myemail@domain.com.au"// Email address to send results

    // Secure or non-secure mode
    $secure 0// Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP

    // Set to 1 to have web page result appear 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 $cpuser.":".$cppass;
    $pass base64_encode($authstr);

    $params "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&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 don't do anything with it.
    while (!feof($socket)) {
      
    $response fgets($socket,4096);
      if (
    $debug) echo $response;
    }

    fclose($socket);

    ?>
    Thank you.....
    Last edited by Infopro; 06-29-2009 at 10:02 PM.

  2. #2
    Registered User anoopkumar's Avatar
    Join Date
    Feb 2004
    Location
    India
    Posts
    6

    Default

    /bin/sh: /home/username/public_html/sender.php: Permission denied

    That does not appear to be an issue with the script. Looks like you have setup the php script /home/username/public_html/sender.php wrongly in the cronjob.

    It should be like

    php /home/username/public_html/sender.php

    If you just give /home/username/public_html/sender.php, system will try to execut it as a shell script, which caused the above error.

  3. #3
    CJL
    CJL is offline
    Member
    Join Date
    Jun 2009
    Posts
    9

    Default

    Thank you for the speedy reply anoopkumar

    I will give it a shot....

  4. #4
    CJL
    CJL is offline
    Member
    Join Date
    Jun 2009
    Posts
    9

    Default

    Ok my cron job just ran now and I received this feedback via email

    X-Powered-By: PHP/5.2.9
    Content-type: text/html

    It didnt actually do anything, it was meant to perform a backup and send it to my hosting account...

    Does anyone know what the problem is???

    cheers

  5. #5
    Member serversphere's Avatar
    Join Date
    Jan 2004
    Posts
    658

    Default

    If you don't set up the script to send the output from the PHP script to null, it will likely email it to you (you probably set up an email address when setting up the cron job, right?)

    If it didn't actually do anything, check the directory where it is running for an error_log file and see what it says is wrong.

  6. #6
    CJL
    CJL is offline
    Member
    Join Date
    Jun 2009
    Posts
    9

    Default

    Quote Originally Posted by serversphere View Post
    If you don't set up the script to send the output from the PHP script to null, it will likely email it to you (you probably set up an email address when setting up the cron job, right?)

    If it didn't actually do anything, check the directory where it is running for an error_log file and see what it says is wrong.
    Unfortunately there was no error log present so I don’t think it was actually running what so ever for an error to occur. Therefore I made some changes to script and got the following error which tells me it is at least running. I believe this error was caused by setting the script to passiveftp. But I have changed that and rescheduled it to run later today. I will let you know how it goes.

    X-Powered-By: PHP/5.2.9
    Content-type: text/html

    <br />
    <b>Warning</b>: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to http://www.domain.com.au:2082 (Unable to find the socket transport &quot;http&quot; - did you forget to enable it when you configured PHP?) in <b>/home/username/public_html/sender.php</b> on line <b>39</b><br /> Failed to open socket connection Bailing out!

  7. #7
    CJL
    CJL is offline
    Member
    Join Date
    Jun 2009
    Posts
    9

    Default

    Has anyone managed to get the Justin Cook backup automation script to actually work? who could advise me on what on earth is going on.

    A summary of the issues I am facing are:
    • It seems that the cron job is running but it does not seem to actually do anything. It does not do a backup and/or send it to my alternative ftp account.
    • I receive the following information in an email but I do not understand what it means.

    X-Powered-By: PHP/5.2.9
    Content-type: text/html

Similar Threads & Tags
Similar threads

  1. WHM Auto Script
    By MeGaMASTER in forum cPanel and WHM Discussions
    Replies: 12
    Last Post: 11-30-2009, 03:27 AM
  2. recursive folders /usr/local/cpanel/perl/auto/auto/auto/auto...
    By bigste in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 10-15-2009, 12:52 AM
  3. Help! I need script for Auto Backup for SQL
    By jeepj27 in forum Database Discussions
    Replies: 1
    Last Post: 09-12-2006, 07:45 PM
  4. Help! I need script for Auto Backup for SQL
    By jeepj27 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-12-2006, 07:45 PM
  5. Auto Restart Script
    By Netsender in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-07-2004, 01:18 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube