Sunday, June 24, 2012

MYSQL: How to set/configure/check backup using crontab

Case: In Ubuntu Server

Normally crontab file locate here:
# nano  /etc/crontab

The rules for crontab can refer in crontab file (backup.sh file)
:
PATH=/usr/local/sbin


or in command line

# m   h  dom mon dow user    command
   00 22   *      *      *   root    sh /usr/local/sbin/automysqlbackup.sh

** 00 22  is time to run the autobackup. The time can be change anytime if needed.


Check the rules in .sh file
# nano  /usr/local/sbin/automysqlbackup.sh

**Important Configuration:

# Username to access the MySQL server e.g. dbuser
USERNAME=dbuser

# Username to access the MySQL server e.g. password
PASSWORD=passworddb

# Host name (or IP address) of MySQL server e.g localhost
DBHOST=10.XX.XX.XX

# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="dbname1 mysql"
#DBNAMES="all"

# Backup directory location e.g /backups
BACKUPDIR="/mnt/archives/backupdb/alimcloud/"

:
# Email Address to send mail to? (user@domain.com)
MAILADDR="email@domain.com.my"

** Just remain default setting for others.

.


0 comments:

Post a Comment