Commit 5ab382ce authored by Antoine Beaupré's avatar Antoine Beaupré Committed by fred

add some of the sqlbackup options to the local.sh global configuration.

note that we discarded some suggestions options:

F_LOG: replaced with syslog
DAEMON: will be considered for inclusion later
VERBOSE/DEBUG: available through command line flags

TYPE_NAME_BACKUP and ALLOW_OVERWRITE_BACKUP are being renamed to
SQLBACKUP_TYPE and SQLBACKUP_OVERWRITE. this is to be more consistent
with the global configurations

See: #1081
parent e12bb9bb
...@@ -33,6 +33,8 @@ ALTERNC_LOC=/var/alternc ...@@ -33,6 +33,8 @@ ALTERNC_LOC=/var/alternc
NS1_HOSTNAME="$FQDN" NS1_HOSTNAME="$FQDN"
NS2_HOSTNAME="$FQDN" NS2_HOSTNAME="$FQDN"
HOSTING="AlternC" HOSTING="AlternC"
SQLBACKUP_TYPE="rotate"
SQLBACKUP_OVERWRITE="no"
if [ -r /etc/alternc/local.sh ]; then if [ -r /etc/alternc/local.sh ]; then
# source the current config # source the current config
...@@ -134,6 +136,18 @@ if [ -z "$RET" ] ...@@ -134,6 +136,18 @@ if [ -z "$RET" ]
db_set alternc/mysql/client "$MYSQL_CLIENT" db_set alternc/mysql/client "$MYSQL_CLIENT"
fi fi
db_get alternc/sql/backup_type
if [ -z "$RET" ]
then
db_set alternc/sql/backup_type "$SQLBACKUP_TYPE"
fi
db_get alternc/sql/backup_overwrite
if [ -z "$RET" ]
then
db_set alternc/sql/backup_overwrite "$SQLBACKUP_OVERWRITE"
fi
db_get alternc/alternc_location db_get alternc/alternc_location
if [ -z "$RET" ] if [ -z "$RET" ]
then then
......
...@@ -93,6 +93,13 @@ ALTERNC_LOC="" ...@@ -93,6 +93,13 @@ ALTERNC_LOC=""
# Networks that SMTP should relay, separated with spaces # Networks that SMTP should relay, separated with spaces
SMTP_RELAY_NETWORKS="" SMTP_RELAY_NETWORKS=""
# the type of backup created by the sql backup script
# valid options are "rotate" (newsyslog-style) or "date" (suffix is the date)
SQLBACKUP_TYPE=""
# overwrite existing files when backing up
SQLBACKUP_OVERWRITE=""
EOF EOF
chown root:www-data $CONFIGFILE chown root:www-data $CONFIGFILE
...@@ -117,6 +124,8 @@ EOF ...@@ -117,6 +124,8 @@ EOF
update_var alternc/bind_internal BIND_INTERNAL update_var alternc/bind_internal BIND_INTERNAL
update_var alternc/default_mx DEFAULT_MX update_var alternc/default_mx DEFAULT_MX
update_var alternc/mysql/client MYSQL_CLIENT update_var alternc/mysql/client MYSQL_CLIENT
update_var alternc/sql/backup_type SQLBACKUP_TYPE
update_var alternc/sql/backup_overwrite SQLBACKUP_OVERWRITE
update_var alternc/alternc_location ALTERNC_LOC update_var alternc/alternc_location ALTERNC_LOC
update_var alternc/mynetwork SMTP_RELAY_NETWORKS update_var alternc/mynetwork SMTP_RELAY_NETWORKS
sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
......
...@@ -136,7 +136,7 @@ function dobck() { ...@@ -136,7 +136,7 @@ function dobck() {
ext="" ext=""
fi fi
# if $TYPE_NAME_BACKUP is set to "rotate" classical rotation files methode will be used # if $SQLBACKUP_TYPE is set to "rotate" classical rotation files methode will be used
# use incrementale number in the name of files where the highest number indicate # use incrementale number in the name of files where the highest number indicate
# the oldest files # the oldest files
# if the rotate type is not set or set to date, the name of the export file will contain the date # if the rotate type is not set or set to date, the name of the export file will contain the date
...@@ -145,9 +145,9 @@ function dobck() { ...@@ -145,9 +145,9 @@ function dobck() {
# rotate files which just change name # rotate files which just change name
# #
# ------------------------------------------------------------------ # # ------------------------------------------------------------------ #
# the variable TYPE_NAME_BACKUP must be set in /etc/alternc/local.sh # # the variable SQLBACKUP_TYPE must be set in /etc/alternc/local.sh #
# ------------------------------------------------------------------ # # ------------------------------------------------------------------ #
if [ $TYPE_NAME_BACKUP == "rotate" ]; then if [ $SQLBACKUP_TYPE == "rotate" ]; then
i="$count" i="$count"
...@@ -199,26 +199,26 @@ function dobck() { ...@@ -199,26 +199,26 @@ function dobck() {
fi fi
# if the backup exite and ALLOW_OVERWRITE_BACKUP is set to NO, cancel backup # if the backup exite and SQLBACKUP_OVERWRITE is set to NO, cancel backup
if [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP" == "no" ] ; then if [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$SQLBACKUP_OVERWRITE" == "no" ] ; then
info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist" info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist"
info " => no backup done as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP" info " => no backup done as specify in allow-overwrite = $SQLBACKUP_OVERWRITE"
DO_BACKUP="NO" DO_BACKUP="NO"
# if the backup exite and ALLOW_OVERWRITE_BACKUP is set to RENAME, add # if the backup exite and SQLBACKUP_OVERWRITE is set to RENAME, add
elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP" == "rename" ] ; then elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$SQLBACKUP_OVERWRITE" == "rename" ] ; then
info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist" info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist"
info " => renaming the new file as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP" info " => renaming the new file as specify in allow-overwrite = $SQLBACKUP_OVERWRITE"
hours=`date +"%H%M"` hours=`date +"%H%M"`
name_backup_file="${name_backup_file}.${hours}" name_backup_file="${name_backup_file}.${hours}"
# if the backup exite and ALLOW_OVERWRITE_BACKUP is set OVERWRITE, add # if the backup exite and SQLBACKUP_OVERWRITE is set OVERWRITE, add
elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP" == "overwrite" ] ; then elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$SQLBACKUP_OVERWRITE" == "overwrite" ] ; then
info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist" info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist"
info " => overwrite file as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP" info " => overwrite file as specify in allow-overwrite = $SQLBACKUP_OVERWRITE"
fi fi
...@@ -291,8 +291,8 @@ read_parameters() { ...@@ -291,8 +291,8 @@ read_parameters() {
-v|--verbose) VERBOSE="ON" ;; -v|--verbose) VERBOSE="ON" ;;
-d|--debug) DEBUG="ON" ;; -d|--debug) DEBUG="ON" ;;
-t|--type) shift; TYPE="$1";; -t|--type) shift; TYPE="$1";;
-n|--name-methode) shift; TYPE_NAME_BACKUP="$1";; -n|--name-methode) shift; SQLBACKUP_TYPE="$1";;
-a|--allow-ovewrite) shift; ALLOW_OVERWRITE_BACKUP="$1" ;; -a|--allow-ovewrite) shift; SQLBACKUP_OVERWRITE="$1" ;;
*) *)
error "invalide option -- $1" error "invalide option -- $1"
error "Try \`sqlbackup.sh --help' for more information." error "Try \`sqlbackup.sh --help' for more information."
...@@ -305,8 +305,8 @@ read_parameters() { ...@@ -305,8 +305,8 @@ read_parameters() {
done done
debug "TYPE = $TYPE" debug "TYPE = $TYPE"
debug "TYPE_NAME_BACKUP = $TYPE_NAME_BACKUP" debug "SQLBACKUP_TYPE = $SQLBACKUP_TYPE"
debug "ALLOW_OVERWRITE_BACKUP = $ALLOW_OVERWRITE_BACKUP" debug "SQLBACKUP_OVERWRITE = $SQLBACKUP_OVERWRITE"
# check options # check options
...@@ -328,19 +328,19 @@ read_parameters() { ...@@ -328,19 +328,19 @@ read_parameters() {
exit exit
fi fi
if ! ( [ -z "$TYPE_NAME_BACKUP" ] || if ! ( [ -z "$SQLBACKUP_TYPE" ] ||
[ "$TYPE_NAME_BACKUP" == "date" ] || [ "$SQLBACKUP_TYPE" == "date" ] ||
[ "$TYPE_NAME_BACKUP" == "rotate" ] ) ; then [ "$SQLBACKUP_TYPE" == "rotate" ] ) ; then
error "invalide argument: name-methode -- $TYPE_NAME_BACKUP" error "invalide argument: name-methode -- $SQLBACKUP_TYPE"
error "Try \`sqlbackup.sh --help' for more information." error "Try \`sqlbackup.sh --help' for more information."
exit exit
fi fi
if ! ( [ -z "$ALLOW_OVERWRITE_BACKUP" ] || if ! ( [ -z "$SQLBACKUP_OVERWRITE" ] ||
[ "$ALLOW_OVERWRITE_BACKUP" == "no" ] || [ "$SQLBACKUP_OVERWRITE" == "no" ] ||
[ "$ALLOW_OVERWRITE_BACKUP" == "rename" ] || [ "$SQLBACKUP_OVERWRITE" == "rename" ] ||
[ "$ALLOW_OVERWRITE_BACKUP" == "overwrite" ] ); then [ "$SQLBACKUP_OVERWRITE" == "overwrite" ] ); then
error "invalide argument: allow-ovewrite -- $ALLOW_OVERWRITE_BACKUP" error "invalide argument: allow-ovewrite -- $SQLBACKUP_OVERWRITE"
error "Try \`sqlbackup.sh --help' for more information." error "Try \`sqlbackup.sh --help' for more information."
exit exit
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment