一个很简单的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

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

转载于:https://my.oschina.net/u/585111/blog/219511

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值