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
This commit is contained in:
Antoine Beaupré 2008-07-10 21:18:42 +00:00
parent 2eb782a9f9
commit a62b9109ed
3 changed files with 48 additions and 25 deletions

14
debian/config vendored
View File

@ -33,6 +33,8 @@ ALTERNC_LOC=/var/alternc
NS1_HOSTNAME="$FQDN"
NS2_HOSTNAME="$FQDN"
HOSTING="AlternC"
SQLBACKUP_TYPE="rotate"
SQLBACKUP_OVERWRITE="no"
if [ -r /etc/alternc/local.sh ]; then
# source the current config
@ -134,6 +136,18 @@ if [ -z "$RET" ]
db_set alternc/mysql/client "$MYSQL_CLIENT"
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
if [ -z "$RET" ]
then

9
debian/postinst vendored
View File

@ -93,6 +93,13 @@ ALTERNC_LOC=""
# Networks that SMTP should relay, separated with spaces
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
chown root:www-data $CONFIGFILE
@ -117,6 +124,8 @@ EOF
update_var alternc/bind_internal BIND_INTERNAL
update_var alternc/default_mx DEFAULT_MX
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/mynetwork SMTP_RELAY_NETWORKS
sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp

View File

@ -136,7 +136,7 @@ function dobck() {
ext=""
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
# the oldest files
# 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() {
# 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"
@ -199,26 +199,26 @@ function dobck() {
fi
# if the backup exite and ALLOW_OVERWRITE_BACKUP is set to NO, cancel backup
if [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP" == "no" ] ; then
# if the backup exite and SQLBACKUP_OVERWRITE is set to NO, cancel backup
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 " => 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"
# if the backup exite and ALLOW_OVERWRITE_BACKUP is set to RENAME, add
elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP" == "rename" ] ; then
# if the backup exite and SQLBACKUP_OVERWRITE is set to RENAME, add
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 " => 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"`
name_backup_file="${name_backup_file}.${hours}"
# if the backup exite and ALLOW_OVERWRITE_BACKUP is set OVERWRITE, add
elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP" == "overwrite" ] ; then
# if the backup exite and SQLBACKUP_OVERWRITE is set OVERWRITE, add
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 " => overwrite file as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP"
info " => overwrite file as specify in allow-overwrite = $SQLBACKUP_OVERWRITE"
fi
@ -291,8 +291,8 @@ read_parameters() {
-v|--verbose) VERBOSE="ON" ;;
-d|--debug) DEBUG="ON" ;;
-t|--type) shift; TYPE="$1";;
-n|--name-methode) shift; TYPE_NAME_BACKUP="$1";;
-a|--allow-ovewrite) shift; ALLOW_OVERWRITE_BACKUP="$1" ;;
-n|--name-methode) shift; SQLBACKUP_TYPE="$1";;
-a|--allow-ovewrite) shift; SQLBACKUP_OVERWRITE="$1" ;;
*)
error "invalide option -- $1"
error "Try \`sqlbackup.sh --help' for more information."
@ -305,8 +305,8 @@ read_parameters() {
done
debug "TYPE = $TYPE"
debug "TYPE_NAME_BACKUP = $TYPE_NAME_BACKUP"
debug "ALLOW_OVERWRITE_BACKUP = $ALLOW_OVERWRITE_BACKUP"
debug "SQLBACKUP_TYPE = $SQLBACKUP_TYPE"
debug "SQLBACKUP_OVERWRITE = $SQLBACKUP_OVERWRITE"
# check options
@ -328,19 +328,19 @@ read_parameters() {
exit
fi
if ! ( [ -z "$TYPE_NAME_BACKUP" ] ||
[ "$TYPE_NAME_BACKUP" == "date" ] ||
[ "$TYPE_NAME_BACKUP" == "rotate" ] ) ; then
error "invalide argument: name-methode -- $TYPE_NAME_BACKUP"
if ! ( [ -z "$SQLBACKUP_TYPE" ] ||
[ "$SQLBACKUP_TYPE" == "date" ] ||
[ "$SQLBACKUP_TYPE" == "rotate" ] ) ; then
error "invalide argument: name-methode -- $SQLBACKUP_TYPE"
error "Try \`sqlbackup.sh --help' for more information."
exit
fi
if ! ( [ -z "$ALLOW_OVERWRITE_BACKUP" ] ||
[ "$ALLOW_OVERWRITE_BACKUP" == "no" ] ||
[ "$ALLOW_OVERWRITE_BACKUP" == "rename" ] ||
[ "$ALLOW_OVERWRITE_BACKUP" == "overwrite" ] ); then
error "invalide argument: allow-ovewrite -- $ALLOW_OVERWRITE_BACKUP"
if ! ( [ -z "$SQLBACKUP_OVERWRITE" ] ||
[ "$SQLBACKUP_OVERWRITE" == "no" ] ||
[ "$SQLBACKUP_OVERWRITE" == "rename" ] ||
[ "$SQLBACKUP_OVERWRITE" == "overwrite" ] ); then
error "invalide argument: allow-ovewrite -- $SQLBACKUP_OVERWRITE"
error "Try \`sqlbackup.sh --help' for more information."
exit
fi