#!/usr/bin/env bash
#
# return true, if variable is set; else false
isSet() {
if [[ ! ${!1} && ${!1-_} ]]; then return 1; else return 0; fi
}
activateIO() {
touch "$1"
exec 6>&1
exec > "$1"
}
removeIO() {
exec 1>&6 6>&-
}
upgrade_config_file () {
( # execute in subshell, so that sourced variables are only available inside ()
source "$1"
#declare -p
local temp
temp=$(mktemp /tmp/tmp.XXXXXX)
(( $? != 0 )) && return 1
activateIO "$temp"
echo "#version=3.0_rc2"
echo "# Uncomment to change the default values (shown after =)"
echo "# WARNING:"
echo "# This is not true for UMASK, CONFIG_prebackup and CONFIG_postbackup!!!"
echo "#"
echo "# Default values are stored in the script itself. Declarations in"
echo "# /etc/automysqlbackup/automysqlbackup.conf will overwrite them. The"
echo "# declarations in here will supersede all other."
echo ""
echo "# Edit \$PATH if mysql and mysqldump are not located in /usr/local/bin:/usr/bin:/bin:/usr/local/mysql/bin"
echo "#PATH=\${PATH}:FULL_PATH_TO_YOUR_DIR_CONTAINING_MYSQL:FULL_PATH_TO_YOUR_DIR_CONTAINING_MYSQLDUMP"
echo ""
echo "# Basic Settings"
echo ""
echo "# Username to access the MySQL server e.g. dbuser"
if isSet USERNAME; then
printf '%s=%q\n' CONFIG_mysql_dump_username "${USERNAME-}"
else
echo "#CONFIG_mysql_dump_username='root'"
fi
echo ""
echo "# Password to access the MySQL server e.g. password"
if isSet PASSWORD; then
printf '%s=%q\n' CONFIG_mysql_dump_password "${PASSWORD-}"
else
echo "#CONFIG_mysql_dump_password=''"
fi
echo ""
echo "# Host name (or IP address) of MySQL server e.g localhost"
if isSet DBHOST; then
printf '%s=%q\n' CONFIG_mysql_dump_host "${DBHOST-}"
else
echo "#CONFIG_mysql_dump_host='localhost'"
fi
echo ""
echo "# \"Friendly\" host name of MySQL server to be used in email log"
echo "# if unset or empty (default) will use CONFIG_mysql_dump_host instead"
if isSet CONFIG_mysql_dump_host_friendly; then
printf '%s=%q\n' CONFIG_mysql_dump_host_friendly "${CONFIG_mysql_dump_host_friendly-}"
else
echo "#CONFIG_mysql_dump_host_friendly=''"
fi
echo ""
echo "# Backup directory location e.g /backups"
if isSet BACKUPDIR; then
printf '%s=%q\n' CONFIG_backup_dir "${BACKUPDIR-}"
else
echo "#CONFIG_backup_dir='/var/backup/db'"
fi
echo ""
echo "# This is practically a moot point, since there is a fallback to the compression"
echo "# functions without multicore support in the case that the multicore versions aren't"
echo "# present in the system. Of course, if you have the latter installed, but don't want"
echo "# to use them, just choose no here."
echo "# pigz -> gzip"
echo "# pbzip2 -> bzip2"
echo "#CONFIG_multicore='yes'"
echo ""
echo "# Number of threads (= occupied cores) you want to use. You should - for the sake"
echo "# of the stability of your system - not choose more than (#number of cores - 1)."
echo "# Especially if the script is run in background by cron and the rest of your system"
echo "# has already heavy load, setting this too high, might crash your system. Assuming"
echo "# all systems have at least some sort of HyperThreading, the default is 2 threads."
echo "# If you wish to let pigz and pbzip2 autodetect or use their standards, set it to"
echo "# 'auto'."
echo "#CONFIG_multicore_threads=2"
echo ""
echo "# Databases to backup"
echo ""
echo "# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )"
echo "# set to (), i.e. empty, if you want to backup all databases"
if isSet DBNAMES; then
if [[ "x$DBNAMES" = "xall" ]]; then
echo "#CONFIG_db_names=()"
else
declare -a CONFIG_db_names
for i in $DBNAMES; do
CONFIG_db_names=( "${CONFIG_db_names[@]}" "$i" )
done
declare -p CONFIG_db_names | sed -e 's/\[[^]]*]=//g'
fi
else
echo "#CONFIG_db_names=()"
fi
echo "# You can use"
echo "#declare -a MDBNAMES=( \"\${DBNAMES[@]}\" 'added entry1' 'added entry2' ... )"
echo "# INSTEAD to copy the contents of \$DBNAMES and add further entries (optional)."
echo ""
echo "# List of databases for Monthly Backups."
echo "# set to (), i.e. empty, if you want to backup all databases"
if isSet MDBNAMES; then
if [[ "x$MDBNAMES" = "xall" ]]; then
echo "#CONFIG_db_month_names=()"
else
declare -a CONFIG_db_month_names
for i in $MDBNAMES; do
CONFIG_db_month_names=( "${CONFIG_db_month_names[@]}" "$i" )
done
declare -p CONFIG_db_month_names | sed -e 's/\[[^]]*]=//g'
fi
else
echo "#CONFIG_db_month_names=()"
fi
echo ""
echo "# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. ()."
if isSet DBEXCLUDE; then
declare -a CONFIG_db_exclude
for i in $DBEXCLUDE; do
CONFIG_db_exclude=( "${CONFIG_db_exclude[@]}" "$i" )
done
declare -p CONFIG_db_exclude | sed -e 's/\[[^]]*]=//g'
else
echo "#CONFIG_db_exclude=( 'information_schema' )"
fi
echo ""
echo "# List of tables to exclude, in the form db_name.table_name"
echo "#CONFIG_table_exclude=()"
echo ""
echo ""
echo "# Advanced Settings"
echo ""
echo "# Rotation Settings"
echo ""
echo "# Which day do you want monthly backups? (01 to 31)"
echo "# If the chosen day is greater than the last day of the month, it will be done"
echo "# on the last day of the month."
echo "# Set to 0 to disable monthly backups."
echo "#CONFIG_do_monthly=\"01\""
echo ""
echo "# Which day do you want weekly backups? (1 to 7 where 1 is Monday)"
echo "# Set to 0 to disable weekly backups."
if isSet DOWEEKLY; then
printf '%s=%q\n' CONFIG_do_weekly "${DOWEEKLY-}"
else
echo "#CONFIG_do_weekly=\"5\""
fi
echo ""
echo "# Set rotation of daily backups. VALUE*24hours"
echo "# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed."
echo "#CONFIG_rotation_daily=6"
echo ""
echo "# Set rotation for weekly backups. VALUE*24hours"
echo "#CONFIG_rotation_weekly=35"
echo ""
echo "# Set rotation for monthly backups. VALUE*24hours"
echo "#CONFIG_rotation_monthly=150"
echo ""
echo ""
echo "# Server Connection Settings"
echo ""
echo "# Set the port for the mysql connection"
echo "#CONFIG_mysql_dump_port=3306"
echo ""
echo "# Compress communications between backup server and MySQL server?"
if isSet COMMCOMP; then
printf '%s=%q\n' CONFIG_mysql_dump_commcomp "${COMMCOMP-}"
else
echo "#CONFIG_mysql_dump_commcomp='no'"
fi
echo ""
echo "# Use ssl encryption with mysqldump?"
echo "#CONFIG_mysql_dump_usessl='yes'"
echo ""
echo "# For connections to localhost. Sometimes the Unix socket file must be specified."
if isSet SOCKET; then
printf '%s=%q\n' CONFIG_mysql_dump_socket "${SOCKET-}"
else
echo "#CONFIG_mysql_dump_socket=''"
fi
echo ""
echo "# The maximum size of the buffer for client/server communication. e.g. 16MB (maximum is 1GB)"
if isSet MAX_ALLOWED_PACKET; then
printf '%s=%q\n' CONFIG_mysql_dump_max_allowed_packet "${MAX_ALLOWED_PACKET-}"
else
echo "#CONFIG_mysql_dump_max_allowed_packet=''"
fi
echo ""
echo "# This option sends a START TRANSACTION SQL statement to the server before dumping data. It is useful only with"
echo "# transactional tables such as InnoDB, because then it dumps the consistent state of the database at the time"
echo "# when BEGIN was issued without blocking any applications."
echo "#"
echo "# When using this option, you should keep in mind that only InnoDB tables are dumped in a consistent state. For"
echo "# example, any MyISAM or MEMORY tables dumped wh
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
解压后执行 install.sh 命令 ### Checking archive files for existence, readability and integrity. automysqlbackup ... exists and is readable ... md5sum okay :) automysqlbackup.conf ... exists and is readable ... md5sum okay :) README ... exists and is readable ... md5sum okay :) LICENSE ... exists and is readable ... md5sum okay :) Select the global configuration directory [/etc/automysqlbackup]: Select directory for the executable [/usr/local/bin]: /usr/bin
资源推荐
资源详情
资源评论
收起资源包目录
backupV3.0.zip (6个子文件)
backupV3.0
automysqlbackup.conf 12KB
README 7KB
LICENSE 18KB
automysqlbackup 87KB
install.sh 21KB
CHANGELOG 9KB
共 6 条
- 1
资源评论
童龙辉
- 粉丝: 1615
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于ESP8266和Arduino的HomeMatic水表读数系统.zip
- (源码)基于Django和OpenCV的智能车视频处理系统.zip
- (源码)基于ESP8266的WebDAV服务器与3D打印机管理系统.zip
- (源码)基于Nio实现的Mycat 2.0数据库代理系统.zip
- (源码)基于Java的高校学生就业管理系统.zip
- (源码)基于Spring Boot框架的博客系统.zip
- (源码)基于Spring Boot框架的博客管理系统.zip
- (源码)基于ESP8266和Blynk的IR设备控制系统.zip
- (源码)基于Java和JSP的校园论坛系统.zip
- (源码)基于ROS Kinetic框架的AGV激光雷达导航与SLAM系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功