Total Pageviews

Thursday, 3 March 2016

用Automysqlbackup备份mysql数据库


Automysqlbackup是一个非常不错的轻量级Mysql自动备份脚本,你可以在http://sourceforge.net/projects/automysqlbackup/files/AutoMySQLBackup/ 下载到最新的版本,经过简单的配置之后添加到系统的周期执行列表中去即可简单实现mysql自
动备份的功能。但是这么一个简洁而强大的工具在FreeBSD下使用的时候会提示如下的错误:

./automysqlbackup.sh.2.5: Command not found.
这是因为FreeBSD下默认是没有装bash的,而且即使通过PORTS安装之后相对于脚本中的位置也是不对的,要解决这个问题可以修改脚本中的bash
shell路径为#!/bin/sh,或者是用PORTS安装Bash之后将路径#!/usr/local/bin/bash

PS:备份脚本中要修改的内容一般只有如下

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

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

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

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

# Backup directory location e.g /backups
BACKUPDIR="/srv/backup/db"

# Mail setup
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
MAILCONTENT="log"

# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
MAXATTSIZE="4000"

# Email Address to send mail to? (user@domain.com)
MAILADDR="maintenance@example.com"