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.

Cron Job Backup Question

Discussion in 'General Discussion' started by zargon, Mar 13, 2004.

  1. zargon

    zargon Registered

    Joined:
    Mar 8, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I am a bit new to this so please cut me some slack, I am sure it is a simple answer.

    In Cpanel I want to do a full back up of all information every 24 hours.

    I have been sucessful in manually creating the back up and then sending it to another server as well as downloading it to my local computer. I would like for this to atomatically have the backup happen automatically and then send the back up to another server.

    What command or script would I use to do this in the
    "Comman to run" box of the cron manager in Cpanel.

    Assume the default folder in the other server is "backup"

    Thanks for any help
     
  2. ddeans

    ddeans Well-Known Member

    Joined:
    Feb 13, 2004
    Messages:
    296
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Maryland
    Is this your server or some one else's?
     
  3. zargon

    zargon Registered

    Joined:
    Mar 8, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I do not own the server, I am a shared user on the server which is actually located in colorado.

    To be more specfic I rent space on the main server with my own space including Cpanel and WHM.

    I have several user accounts domain names & web space) that include Cpanel and need to do backups in case of disaster.
     
    #3 zargon, Mar 13, 2004
    Last edited: Mar 13, 2004
  4. marcan

    marcan Registered

    Joined:
    Apr 23, 2004
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Montreal | Canada
    zargon : did you find an answer to your question ? I am trying to find the answer too !
     
  5. zargon

    zargon Registered

    Joined:
    Mar 8, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Marcan,

    No one ever answered my query, either no one knows or else they are just ignoring the request.

    I have been doing a bit of research however and may have a solution to the cron job back up problem with automatic ftp to the server of your choice.

    However, the backup cron job script won't backup MySql as of yet, but time will cure all things.

    Keep in touch and I will let you know when I come up with something solid.

    Cheers
     
  6. Big Gorilla

    Big Gorilla Active Member

    Joined:
    Jan 30, 2004
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    I wrote this awhile ago based on a code snippet idea I found on here. Feel free to use it if you find it useful. All it does is automate calling the cPanel full backup. What you need to configure should be relatively simple to figure out.

    Since this script stores your password, you should keep it somewhere secure (not in your public_html directories), and set the permissions to 600. You could even run it on a remote machine if you wanted to (but I'd strongly recommend using the SSL option in that case...make sure your PHP has SSL support).

    You can cron as something like:
    30 3 * * * /usr/local/bin/php /home/youraccount/fullbackup.php

    For the discussion on it, you can go here.

    PHP:
    <?php

    // PHP script to allow periodic cPanel backups automatically.
    // Based on script posted by max.hedroom in cpanel.net forums
    //   This script contains passwords.  KEEP ACCESS TO THIS FILE SECURE!

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

    // Info required for cPanel access
    $cpuser "username"// Username used to login to CPanel
    $cppass "password"// Password used to login to CPanel
    $domain "example.com"// Domain name where CPanel is run
    $skin "monsoon"// Set to cPanel skin you use (script won't work if it doesn't match)

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

    // Notification information
    $notifyemail "you@example.com"// 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);

    ?>
     
Loading...

Share This Page