chillnet.co.za

How to backup all your MySQL Databases on a Daily basis using a CentOS operating system PDF Print E-mail
Tuesday, 21 July 2009 06:41

Please note:

You might need root access to the server.

Create a new file in /etc/cron.daily called mysql-backup.cron

vi /etc/cron.daily/mysql-backup.cron

Add the following in that file:

#!/bin/sh
date=`date -I`
mysqldump -uroot -pYOUR_ROOT_MYSQL_PASSWORD --opt --all-databases | gzip -c > /WHERE/YOU/WOULD/LIKE/TO/STORE/YOUR/BACKUPS/$date.sql.gz

The first line contains the Shebang.

The second line creates a variable containing today's date. Example:  YYYY-MM-DD

The 3rd line will use the mysqldump utility, log in as root, then dump all your databases and pipe the output to gzip where you'd like to store your file.

You might want to consider to add the following to your cron as well:

tmpwatch 672 /WHERE/YOU/WOULD/LIKE/TO/STORE/YOUR/BACKUPS/

This will ensure that you're disk space won't be used up eventually.  All files older than 673 hours (± 1 Month) would be removed after you've made your backups.

 

Last Updated ( Thursday, 20 August 2009 13:44 )
 

Signup For Fax2Email

 
Get your free Fax2Email number
 
Email Address:
Contact Name:
Contact Number:
 
 

Random Products

International Domain Name Registration
International Domain Name Registration
R150.00


.co.za Domain Name Registration
.co.za Domain Name Registration
R100.00


Google Ads

Banner