Activity Stream
48,167 MEMBERS
6921 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 2 of 2
  1.     
    #1
    Member

    Default Cron command for Full Website Backup?

    Does anyone know the cPanel cron command for Full Website Backup?
    LEVAC109 Reviewed by LEVAC109 on . Cron command for Full Website Backup? Does anyone know the cPanel cron command for Full Website Backup? Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    First try this:

    Code: 
    0	0	*	*	0 	mysqldump ?u database_user ?pDatabase-Password database_name > database_name-`date ?+%Y-%m-%d?`.sql
    If the above command isn't working then make this script.

    The script is working in a cron job which uploads backup file at every 6 hours, then it will overwrite older backup file. If anyone wants to have backup every hour, you have to make changes accordingly in crontab file.

    Script name is: daybackup.script.sh

    Code: 
    #!/bin/sh
    # Put FTP server details here
    SERVER="Remote FTP server"
    USERNAME="FTP user"
    PASSWORD="FTP password"
    
    # local directory containing source backup file
    SOURCEFILES="/home/mybackup"
    
    # remote server directory path in which backup needs to be put in
    BACKUPDIRCTORY="/rsystem/backupdir/"
    
    # login to remote server
    ftp -n -i $SERVER <<EOF
    user $USERNAME $PASSWORD
    cd $ BACKUPDIRCTORY
    
    mput $ SOURCEFILES/*.tar.gz
    quit
    EOF
    Make another file using same code given above and give a name to that file as: nightbackup.script.sh as it will put backup to remote system at midnight.
    Both the script should have executable permissions, like:

    Code: 
    $ chmod +x daybackup.script.sh
    $ chmod +x nightbackup.script.sh
    Now we have to setup a cron job to run above script at regular intervals.

    You need to edit your crontab file. Enter the following command:

    $ crontab -e

    Following lines should append to available code as there may be a chance to have some another job running in the crontab file.

    0 12 * * * daybackup.script.sh >>/tmp/backup.log 2>&1
    0 0 * * * nightbackup.script.sh >>/tmp/backup.log 2>&1


    Save and close the file.

    To store the output of cron commands, we have used /tmp/backup.log file.

    Please use crontab ?l command to confirm crontab job uses above code or not.

    Note: In the above script /home/mybackup folder contains tar.gz files. One has to write a separate script to generate those source backup file.

    If the above script isn't working for you then try this script.

    Code: 
    #! /usr/bin/env python2
    
    import os
    import sys
    import time
    
    database = sys.argv[1]
    location = sys.argv[2]
    
    location = location.replace("DAY", time.strftime("%d"))
    location = location.replace("MONTH", time.strftime("%m"))
    location = location.replace("YEAR", time.strftime("%y"))
    location = location.replace("HOUR", time.strftime("%H"))
    location = location.replace("MIN", time.strftime("%M"))
    location = location.replace("SEC", time.strftime("%S"))
    
    command = "mysqldump "+database+" > "+location+".sql"
    print command
    os.system(command)
    command = "tar -czvf "+location+" "+location+".sql"
    print command
    os.system(command)
    command = "rm -f "+location+".sql"
    print command
    os.system(command)
    crontab

    Code: 
    0 4 * * * path to above file dbtoback /home/dbtobackbackup_DAY-MONTH-YEAR.tar.gz
    Link Building - Contact me for 20% discount
    Learn SEO - SEFlame.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How can I create a full system image backup within ubuntu ?
    By ahmadka in forum Technical Help Desk Support
    Replies: 4
    Last Post: 3rd Aug 2011, 08:30 AM
  2. Creat full backup with MySQLDumper ?
    By 3xupdate in forum Technical Help Desk Support
    Replies: 12
    Last Post: 4th Jul 2011, 03:28 PM
  3. Replies: 10
    Last Post: 15th Sep 2010, 04:46 PM
  4. Backup cron jobs
    By FancyPants in forum phpBB
    Replies: 8
    Last Post: 7th Mar 2010, 06:34 PM
  5. How to restore a full backup?
    By ceekeigh in forum vBulletin
    Replies: 6
    Last Post: 23rd Oct 2009, 01:13 AM

Tags for this Thread

BE SOCIAL