#!/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
童龙辉
- 粉丝: 1928
- 资源: 10
最新资源
- 市建设工程安全生产标准化管理优良工地申报表.docx
- 特殊建设工程消防验收现场评定(其他建设工程消防验收备案现场检查)监督记录表.docx
- 提前报废老旧营运柴油货车补贴标准、新购营运货车补贴标准表.docx
- 基于鸟鸣声识别的鸟类分类系统项目源代码全套技术资料.zip
- 解析XML文件,使用ElementTree模块,并根据流程图设计合适的数据结构保存解析结果-使用Python ElementTree模块解析XML文件并设计数据结构-含源代码及解释
- 膝关节功能丧失程度评定表.docx
- 外出务工就业交通补助申报表.docx
- 腕关节功能丧失程度评定表.docx
- 现场评定检查表—— 防爆.docx
- 现场评定检查表—— 防火分隔、固定窗.docx
- 现场评定检查表——安全疏散.docx
- 现场评定检查表——建筑类别与耐火等级表.docx
- 现场评定检查表——建筑灭火器.docx
- 现场评定检查表--泡沫灭火系统.docx
- 现场评定检查表——平面布置.docx
- 现场评定检查表——建筑内部装修防火.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈