Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057

    Backup Server Script Problems

    Hi, the script below with all the cPanel details filled in, is suppose to back up my server and write the entire server backup to a directory, this is not working ?



    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 = "cpaneluser"; // Username used to login to CPanel
        $cppass = "cpanelpw"; // Password used to login to CPanel
        $domain = "mycpanel.website.com:port"; // Domain name where CPanel is run and the port. I had to put the port here to get it to work.
        $skin = "x3"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme (I was running x3)
        // Info required for FTP host
        $ftpuser = "username"; // Username for FTP account
        $ftppass = "password"; // Password for FTP account
        $ftphost = "website.com"; // Full hostname or IP address for FTP host
        $ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)
        $ftpport = "21"; // FTP Port (21 default)
        $ftprdir = "backupdir"; // Backup Directory
        // Notification information
        $notifyemail = "notifyme@website.com"; // Email address to send results
        // Secure or non-secure mode
        $secure = 1; // 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&port=$ftpport&rdir=$ftprdir&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);
        ?>

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    Are there any error meesages, or is it just not backing it up, or do you have a blank white page? Describe what is not working.


  4. #3
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    The script is not creating a back up of the server, which includes all the directories. CronJob is working, each night I get a email informing me that the script works, there is nothing backed up in the directory that I told the script to backup too.

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    What happens when you run the Cron job manually? If it's a script, there should be a web page associated with it (I'm guessing you used wget (URL) for your Cron job).
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    CronJobs is executing the script and only the script. The script purpose is to backup the web server to a directory on the server, that is not happening.

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    That wasn't the question, dude. I get the Cron job is executing something.. But just because it's doing that doesn't mean that the script itself is configured correctly or working. The only way you can figure that out that I can think of is to open up the script that it's running in a browser and see if there are any errors.

    Maybe there's a credentials issue. Maybe it's a permissions thing. Maybe it's something completely different. But unless you open up that script yourself and see if there are any errors, you won't know.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  8. #7
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    When CronJobs executes the script it says; "I work Script 2".

  9. #8
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    have you tried it in SSL mode and NON ssl mode ?

  10. #9
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Again, forget Cron for a bit. Pretend like you have to run the script manually.

    It's a PHP, which means there's likely a page of the form http://(domain.com)/your-cron-job.php. Open that page up in a web browser and see what you see. That​ is where you'll find your information.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  11. #10
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    I have run the script manually, again the script says;
    I work Script 2


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:31 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com