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.

Want to set up a simple Cron Job for Automatic Full Backups.

Discussion in 'Data Protection' started by hectron, Oct 21, 2011.

  1. hectron

    hectron Registered

    Joined:
    Oct 21, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Hi everyone,

    I was perusing through the forums and kept on seeing a lot of different solutions to do this but I wanted to keep things simple.

    I am using cPanel 11.30.4 build 6 running linux.

    Objective: I wanted to run a cron job on a daily basis, scheduled to run at 9 P.M. The backups are to be saved in the /home/foo directory. I plan on writing a simple .sh script which is to be executed, triggering the nightly full backup.


    Here are the steps which I have taken:



    Within the main console, I navigate down to Cron jobs. A new cron job is set up with the following settings:

    Minute: 0
    Hour: 21
    Day: *
    Month: *
    Weekday: *

    Command:
    Code:
    sh /home/foo/backup.sh
    This is the code within backup.sh:

    Code:
    #!/bin/sh
    
    
    wget -O /dev/null -q –no-check-certificate –http-user=$1 –http-password=$2 https://foo.hostgator.com:port/frontend/x3/backup/fullbackup.html –post-data=”dest=homedir&email=$3&email_radio=1&user=$1&pass=$2″
    
    Issue: To verify that the script is working, I have changed the cron schedule to run every 3 minutes. I have not received any e-mails regarding whether or not the script has been run.

    Ideas: I thought that this might have something to do with wget and https. To resolve that issue, I used the -no-check-certificate.

    Any ideas where I can be going wrong?


    EDIT: I got in contact with the HostGator.com representatives and it seems that a lot of this lies on the script. Furthermore, cron jobs are only allowed every 15 minutes for my type of account. As a result, they were not running.

    I tweaked everything a little bit.

    The command is now:

    Code:
    /home/foo/backup.sh "username" "password" "email" 2>>/home/foo/error.log
     
    #1 hectron, Oct 21, 2011
    Last edited: Oct 21, 2011
  2. minosjl

    minosjl Well-Known Member

    Joined:
    Jun 4, 2011
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    Root Administrator
    hi,

    The file name is dofullbackup.html not fullbackup.html .I think the error is because of this.Could you please check out the link given below.I think in this link they have explained every thing about this and also have a video tutorial.

    How To Automate Your Web Server Backups
     
  3. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Check out the wget manual page, the word-based options need to be preceded by "--" instead of "-" ...
     
  4. storminternet

    storminternet Well-Known Member

    Joined:
    Nov 2, 2011
    Messages:
    462
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Hi,

    Put the full path of wget binary in cron. For example put /usr/bin/wget instead only wget
     
  5. hectron

    hectron Registered

    Joined:
    Oct 21, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    DataCenter Provider
    Thank you for the advice, all. I ended up changing the page name "fullbackup.html" to "dofullbackup.html" as minosjl suggested and that did the trick.

    Thank you all!
     
  6. storminternet

    storminternet Well-Known Member

    Joined:
    Nov 2, 2011
    Messages:
    462
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Not a problem!!!
     
Loading...

Share This Page