一个很简单的MYSQL数据库备份脚本

只是一个完全备份,等增量备份写好了发上来。



假设有三个库
m_site,m_bbs,m_cms.

#!/bin/sh
#
# MySQL Backup Scripts.
# Created by david.
#
# Created time:2008-01-09 11:10:49
#
USERNAME=backup_user
PASSWORD=123456
case "$1" in
  m_site) BACKUP_FILE=/home/david_yeung/backup/backup_m_site`date '+%Y%m%d_%H%M%S'`.sql ;;
  m_bbs) BACKUP_FILE=/home/david_yeung/backup/backup_m_bbs`date '+%Y%m%d_%H%M%S'`.sql ;;
  m_cms) BACKUP_FILE=/home/david_yeung/backup/backup_m_cms`date '+%Y%m%d_%H%M%S'`.sql ;;
  *) ;;
esac
# Start backup.
/usr/local/mysql/bin/mysqldump -u$USERNAME -p$PASSWORD -B $1 --add-drop-table -R > $BACKUP_FILE

# Compress backup file.
gzip $BACKUP_FILE


加入到CRONTAB里面去。
[david_yeung]# crontab -l
0 0 * * * /home/david_yeung/mysqlbackup_david m_site
0 0 * * * /home/david_yeung/mysqlbackup_david m_bbs
0 0 * * * /home/david_yeung/mysqlbackup_david m_cms

本文出自 “上帝,咱们不见不散!” 博客,转载请与作者联系!

你可能感兴趣的:(mysql,数据库,职场,休闲,备份脚本)