Changeset 2259

Show
Ignore:
Timestamp:
07/10/08 23:18:42 (2 months ago)
Author:
anarcat
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/debian/config

    r2158 r2259  
    3434NS2_HOSTNAME="$FQDN" 
    3535HOSTING="AlternC" 
     36SQLBACKUP_TYPE="rotate" 
     37SQLBACKUP_OVERWRITE="no" 
    3638 
    3739if [ -r /etc/alternc/local.sh ]; then 
     
    135137fi 
    136138 
     139db_get alternc/sql/backup_type 
     140if [ -z "$RET" ] 
     141    then 
     142db_set alternc/sql/backup_type "$SQLBACKUP_TYPE" 
     143fi 
     144 
     145db_get alternc/sql/backup_overwrite 
     146if [ -z "$RET" ] 
     147    then 
     148db_set alternc/sql/backup_overwrite "$SQLBACKUP_OVERWRITE" 
     149fi 
     150 
    137151db_get alternc/alternc_location 
    138152if [ -z "$RET" ] 
  • alternc/trunk/debian/postinst

    r2117 r2259  
    9494# Networks that SMTP should relay, separated with spaces 
    9595SMTP_RELAY_NETWORKS="" 
     96 
     97# the type of backup created by the sql backup script 
     98# valid options are "rotate" (newsyslog-style) or "date" (suffix is the date) 
     99SQLBACKUP_TYPE="" 
     100 
     101# overwrite existing files when backing up 
     102SQLBACKUP_OVERWRITE="" 
    96103EOF 
    97104 
     
    118125    update_var alternc/default_mx DEFAULT_MX  
    119126    update_var alternc/mysql/client MYSQL_CLIENT  
     127    update_var alternc/sql/backup_type SQLBACKUP_TYPE 
     128    update_var alternc/sql/backup_overwrite SQLBACKUP_OVERWRITE 
    120129    update_var alternc/alternc_location ALTERNC_LOC 
    121130    update_var alternc/mynetwork SMTP_RELAY_NETWORKS 
  • alternc/trunk/src/sqlbackup.sh

    r2258 r2259  
    137137        fi 
    138138 
    139         # if $TYPE_NAME_BACKUP is set to "rotate" classical rotation files methode will be used 
     139        # if $SQLBACKUP_TYPE is set to "rotate" classical rotation files methode will be used 
    140140        # use incrementale number in the name of files where the highest number indicate 
    141141        # the oldest files 
     
    146146        # 
    147147        # ------------------------------------------------------------------ # 
    148         # the variable TYPE_NAME_BACKUP must be set in /etc/alternc/local.sh # 
     148        # the variable SQLBACKUP_TYPE must be set in /etc/alternc/local.sh # 
    149149        # ------------------------------------------------------------------ # 
    150         if [ $TYPE_NAME_BACKUP == "rotate" ]; then  
     150        if [ $SQLBACKUP_TYPE == "rotate" ]; then  
    151151             
    152152            i="$count" 
     
    200200       fi 
    201201       
    202        # if the backup exite and ALLOW_OVERWRITE_BACKUP is set to NO, cancel backup 
    203        if [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP"  == "no" ] ; then 
     202       # if the backup exite and SQLBACKUP_OVERWRITE is set to NO, cancel backup 
     203       if [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$SQLBACKUP_OVERWRITE"  == "no" ] ; then 
    204204            
    205205           info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist" 
    206            info "              => no backup done as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP
     206           info "              => no backup done as specify in allow-overwrite = $SQLBACKUP_OVERWRITE
    207207           DO_BACKUP="NO" 
    208208 
    209         # if the backup exite and ALLOW_OVERWRITE_BACKUP is set to RENAME, add   
    210         elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP"  == "rename" ] ; then 
     209        # if the backup exite and SQLBACKUP_OVERWRITE is set to RENAME, add   
     210        elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$SQLBACKUP_OVERWRITE"  == "rename" ] ; then 
    211211 
    212212           info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist" 
    213            info "              => renaming the new file as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP
     213           info "              => renaming the new file as specify in allow-overwrite = $SQLBACKUP_OVERWRITE
    214214           hours=`date +"%H%M"`  
    215215           name_backup_file="${name_backup_file}.${hours}" 
    216216 
    217         # if the backup exite and ALLOW_OVERWRITE_BACKUP is set OVERWRITE, add   
    218         elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$ALLOW_OVERWRITE_BACKUP"  == "overwrite" ] ; then 
     217        # if the backup exite and SQLBACKUP_OVERWRITE is set OVERWRITE, add   
     218        elif [ -f "${target_dir}/${name_backup_file}.sql${ext}" ] && [ "$SQLBACKUP_OVERWRITE"  == "overwrite" ] ; then 
    219219 
    220220           info "sqlbackup.sh: ${target_dir}/${name_backup_file}.sql${ext}: already exist" 
    221            info "              => overwrite file as specify in allow-overwrite = $ALLOW_OVERWRITE_BACKUP
     221           info "              => overwrite file as specify in allow-overwrite = $SQLBACKUP_OVERWRITE
    222222            
    223223       fi 
     
    292292            -d|--debug) DEBUG="ON" ;; 
    293293            -t|--type) shift; TYPE="$1";; 
    294             -n|--name-methode) shift; TYPE_NAME_BACKUP="$1";; 
    295             -a|--allow-ovewrite) shift; ALLOW_OVERWRITE_BACKUP="$1" ;; 
     294            -n|--name-methode) shift; SQLBACKUP_TYPE="$1";; 
     295            -a|--allow-ovewrite) shift; SQLBACKUP_OVERWRITE="$1" ;; 
    296296            *) 
    297297                error "invalide option -- $1"  
     
    306306 
    307307    debug "TYPE = $TYPE" 
    308     debug "TYPE_NAME_BACKUP = $TYPE_NAME_BACKUP
    309     debug "ALLOW_OVERWRITE_BACKUP = $ALLOW_OVERWRITE_BACKUP
     308    debug "SQLBACKUP_TYPE = $SQLBACKUP_TYPE
     309    debug "SQLBACKUP_OVERWRITE = $SQLBACKUP_OVERWRITE
    310310    
    311311 
     
    329329    fi 
    330330 
    331     if ! ( [ -z "$TYPE_NAME_BACKUP" ] ||  
    332            [ "$TYPE_NAME_BACKUP" == "date" ] ||  
    333            [ "$TYPE_NAME_BACKUP" == "rotate" ] ) ; then 
    334         error "invalide argument: name-methode -- $TYPE_NAME_BACKUP
     331    if ! ( [ -z "$SQLBACKUP_TYPE" ] ||  
     332           [ "$SQLBACKUP_TYPE" == "date" ] ||  
     333           [ "$SQLBACKUP_TYPE" == "rotate" ] ) ; then 
     334        error "invalide argument: name-methode -- $SQLBACKUP_TYPE
    335335        error "Try \`sqlbackup.sh --help' for more information." 
    336336        exit 
    337337     fi 
    338338 
    339     if ! ( [ -z  "$ALLOW_OVERWRITE_BACKUP" ] ||  
    340            [ "$ALLOW_OVERWRITE_BACKUP" == "no" ] ||  
    341            [ "$ALLOW_OVERWRITE_BACKUP" == "rename" ] ||  
    342            [ "$ALLOW_OVERWRITE_BACKUP" == "overwrite" ] ); then 
    343         error "invalide argument: allow-ovewrite -- $ALLOW_OVERWRITE_BACKUP
     339    if ! ( [ -z  "$SQLBACKUP_OVERWRITE" ] ||  
     340           [ "$SQLBACKUP_OVERWRITE" == "no" ] ||  
     341           [ "$SQLBACKUP_OVERWRITE" == "rename" ] ||  
     342           [ "$SQLBACKUP_OVERWRITE" == "overwrite" ] ); then 
     343        error "invalide argument: allow-ovewrite -- $SQLBACKUP_OVERWRITE
    344344        error "Try \`sqlbackup.sh --help' for more information." 
    345345        exit