View Single Post
  #1  
Old 11-11-2002, 02:36 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default Cron job to back up your db every night

This was posted by rbarclay and may be of use to you all

Quote:
Try this. It is a shell script that will make a compressed dated backup of your whole database (xcart plus whatever other stuff you have in there)

Replace USERNAME and PASSWORD with your info. I have put spaces between each line because I am not sure if with the wrapping it will be easy to follow otherwise. Also you will have to change the paths. my file is called datacollectionbackup.sh. Remember to run "chmod u+x datacollectionbackup.sh" after you create the file to make it executable.

BEGIN SCRIPT FILE

DATE=`date +"%Y-%m-%d-%H%M%S"`

/usr/local/mysql/bin/mysqldump --all-databases --add-drop-table -c -f -F -a -q -u USERNAME --password="PASSWORD" > /usr/backups/mysqldump/data-collection-${DATE}.sql

gzip /usr/backups/mysqldump/data-collection-${DATE}.sql

END SCRIPT FILE

My crontab entry is:

30 01 * * * /root/datacollectionbackup.sh


This runs it at 130 every morning.

good luck
ross
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote