Results 1 to 2 of 2
-
27th Jan 2012, 07:28 AM #1OPMember
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
-
27th Jan 2012, 08:57 AM #2Member
First try this:
Code:0 0 * * 0 mysqldump ?u database_user ?pDatabase-Password database_name > database_name-`date ?+%Y-%m-%d?`.sql
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
Both the script should have executable permissions, like:
Code:$ chmod +x daybackup.script.sh $ chmod +x nightbackup.script.sh
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)
Code:0 4 * * * path to above file dbtoback /home/dbtobackbackup_DAY-MONTH-YEAR.tar.gz
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
How can I create a full system image backup within ubuntu ?
By ahmadka in forum Technical Help Desk SupportReplies: 4Last Post: 3rd Aug 2011, 08:30 AM -
Creat full backup with MySQLDumper ?
By 3xupdate in forum Technical Help Desk SupportReplies: 12Last Post: 4th Jul 2011, 03:28 PM -
Is it possible to extract the database from Full Backup?
By vorazeal in forum phpBBReplies: 10Last Post: 15th Sep 2010, 04:46 PM -
Backup cron jobs
By FancyPants in forum phpBBReplies: 8Last Post: 7th Mar 2010, 06:34 PM -
How to restore a full backup?
By ceekeigh in forum vBulletinReplies: 6Last Post: 23rd Oct 2009, 01:13 AM
themaCreator - create posts from...
Version 3.17 released. Open older version (or...