Changeset 9490

Show
Ignore:
Timestamp:
04/12/10 16:02:32 (3 years ago)
Author:
mbrevda
Message:

re #4167 - make overwriting the backup table optional; version bump

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.8/backup/bin/ampbackup.php

    r9476 r9490  
    9292        $exec.=' --'.$key.'='; 
    9393      break; 
     94      case 'overwritebackup': 
     95        $exec.=' --'.$key.'=yes'; 
     96      break; 
    9497      default: 
    9598        $exec.=' --'.$key.'='.$val; 
     
    109112  if(is_file($opts['budir'].'/'.$opts['name'].'/'.$opts['now'].'.tar.gz')){ 
    110113    $exec='/usr/bin/ssh -o StrictHostKeyChecking=no -i '.$opts['remotesshkey'].' '.$user.$opts['remotesshhost']; 
    111     $exec.=' \'dir='.$rbudir[0].'/backups/'.$opts['name'].'; rm -f $dir/'.$opts['now'].'.tar.gz; if [ ! "$(ls -A $dir)" ]; then rmdir $dir; fi'\''; 
     114    $exec.=' \'dir='.$rbudir[0].'/backups/'.$opts['name'].'; rm -f $dir/'.$opts['now'].'.tar.gz; if [ ! "$(ls -A $dir)" ]; then rmdir $dir; fi\''; 
    112115    exec($exec,$ret); 
    113116  } 
     
    146149      exec($exec,$ret); 
    147150    } 
    148     system('mysqldump --add-drop-table -h'.$amp_conf['AMPDBHOST'].' -u'.$amp_conf['AMPDBUSER'].' -p'.$amp_conf['AMPDBPASS'].' --database '.$amp_conf['AMPDBNAME'].' > /tmp/ampbackups.'.$opts['now'].'/asterisk.sql'); 
     151    $ignorbackup=(($opts['overwritebackup']=='yes')?' --ignore-table='.$amp_conf['AMPDBNAME'].'.backup ':' '); 
     152    system('mysqldump --add-drop-table -h'.$amp_conf['AMPDBHOST'].' -u'.$amp_conf['AMPDBUSER'].' -p'.$amp_conf['AMPDBPASS'].' --database '.$amp_conf['AMPDBNAME'].$ignorbackup.' > /tmp/ampbackups.'.$opts['now'].'/asterisk.sql'); 
    149153  } 
    150154  //backup cdr if requested 
  • modules/branches/2.8/backup/functions.inc.php

    r9391 r9490  
    419419  $advanced=($amp_conf['AMPBACKUPADVANCED']||$opts['sudo']); 
    420420  ?> 
     421  <style type="text/css"> 
     422    tr .tog{cursor:pointer;} 
     423    tr .tog span{color:black} 
     424    <?php 
     425      $sections=array('files','ftp','ssh','email','remote','advanced'); 
     426      foreach($sections as $sec){ 
     427        if(!$$sec){echo '.hide.'.$sec.'{display:none}'."\n";} 
     428      } 
     429      if(!$advanced){echo '.advanced{display:none}'."\n";} 
     430    ?> 
     431    h5{margin-top:10px;margin-bottom:10px} 
     432  </style> 
     433  <script language="javascript" type="text/javascript"> 
     434    $(document).ready(function() { 
     435      $('.tog').click(function(){ 
     436        var tclass = $(this).attr('class'); tclass = tclass.replace('tog ', ''); 
     437        var togspan = $(this).find('span'); 
     438        if(togspan.text()=='+'){ 
     439          togspan.text('- '); 
     440          $('.'+tclass).show(); 
     441        }else{ 
     442          togspan.text('+'); 
     443          $('.'+tclass).not('.tog').hide(); 
     444        } 
     445       }); 
     446       $('.sysconfigdep').click(function(){ 
     447          if($(this).is(':checked')){ 
     448            $('.sysconfig').attr('checked', true); 
     449          } 
     450       }) 
     451       $('.sysconfig').click(function(){ 
     452          if(!$(this).is(':checked')){ 
     453            $('.sysconfigdep').attr('checked', false); 
     454          } 
     455       }) 
     456    }); 
     457  </script> 
    421458  <table> 
    422459  <tr><td colspan="2"><h5><?php echo _("Basic Settings")?><hr></h5></td></tr> 
     
    426463  </tr> 
    427464  <tr> 
    428     <td><a href="#" class="info"><?php echo _("VoiceMail");?><span><?php echo _("Backup the System VoiceMail Boxes... CAUTION: Could result in large file");?></span></a>: </td> 
    429     <td><input type="checkbox" name="voicemail"  tabindex="<?php echo ++$tabindex;?>" value="yes" <?php echo ($opts['voicemail']=='yes')?'checked':''; ?> /></td> 
    430   </tr> 
    431   <tr> 
    432     <td><a href="#" class="info"><?php echo _("System Recordings");?><span><?php echo _("Backup the System Recordings (AutoAttendant, Music On Hold, System Recordings)");?></span></a>: </td> 
    433     <td><input type="checkbox" name="recordings" value="yes" <?php echo ($opts['recordings']=='yes')?'checked':''; ?> /></td> 
    434   </tr> 
    435   <tr> 
    436     <td><a href="#" class="info"><?php echo _("System Configuration");?><span><?php echo _("Backup the System Configurations (Database, etc files, SQL Database, astdb)");?></span></a>: </td> 
    437     <td><input type="checkbox" name="configurations" value="yes" <?php echo ($opts['configurations']=='yes')?'checked':''; ?>/></td> 
     465    <td><a href="#" class="info"><?php echo _("Admin Web Directory");?><span><?php echo _("Backup the admin web directory (i.e. the static FreePBX web files). This is useful to have during a restore to prevent a version mismatch, but can dramatically increase the backup size.");?></span></a>: </td> 
     466    <td><input type="checkbox" name="admin" value="yes" class="sysconfigdep" <?php echo ($opts['admin']=='yes')?'checked':''; ?>/></td> 
    438467  </tr> 
    439468  <tr> 
    440     <td><a href="#" class="info"><?php echo _("Admin Web Directory");?><span><?php echo _("Backup the admin web directory (i.e. the static FreePBX web files). This is useful to have during a restore to prevent a version mismatch, but can dramatically increase the backup size.");?></span></a>: </td> 
    441     <td><input type="checkbox" name="admin" value="yes" <?php echo ($opts['admin']=='yes')?'checked':''; ?>/></td> 
    442   </tr> 
    443   <tr> 
    444469    <td><a href="#" class="info"><?php echo _("CDR");?><span><?php echo _("Backup the System Call Detail Reporting (HTML and Database)");?></span></a>: </td> 
    445470    <td><input type="checkbox" name="cdr" value="yes" <?php echo ($opts['cdr']=='yes')?'checked':''; ?>/></td> 
     
    449474    <td><input type="checkbox" name="fop" value="yes" <?php echo ($opts['fop']=='yes')?'checked':''; ?>/></td> 
    450475  </tr> 
     476  <tr> 
     477    <td><a href="#" class="info"><?php echo _("Ovewrite Backup Settings");?><span><?php echo _("When restoring the backup, if this option is selected, all saved backups and their scheduals will be overwriten. Leaving this unchecked will restore all other configurations EXCEPT for thoes related to backup. WHen doing a remote backup and restore, this option is always forced.");?></span></a>: </td> 
     478    <td><input type="checkbox" name="overwritebackup" value="yes" class="sysconfigdep" <?php echo ($opts['overwritebackup']=='yes')?'checked':''; ?>/></td> 
     479  </tr>  
     480  <tr> 
     481    <td><a href="#" class="info"><?php echo _("System Recordings");?><span><?php echo _("Backup the System Recordings (AutoAttendant, Music On Hold, System Recordings)");?></span></a>: </td> 
     482    <td><input type="checkbox" name="recordings" value="yes" <?php echo ($opts['recordings']=='yes')?'checked':''; ?> /></td> 
     483  </tr> 
     484  <tr> 
     485    <td><a href="#" class="info"><?php echo _("VoiceMail");?><span><?php echo _("Backup the System VoiceMail Boxes... CAUTION: Could result in large file");?></span></a>: </td> 
     486    <td><input type="checkbox" name="voicemail"  tabindex="<?php echo ++$tabindex;?>" value="yes" <?php echo ($opts['voicemail']=='yes')?'checked':''; ?> /></td> 
     487  </tr> 
     488  <tr> 
     489    <td><a href="#" class="info"><?php echo _("System Configuration");?><span><?php echo _("Backup the System Configurations (Database, etc files, SQL Database, astdb)");?></span></a>: </td> 
     490    <td><input type="checkbox" name="configurations" value="yes" class="sysconfig" <?php echo ($opts['configurations']=='yes')?'checked':''; ?>/></td> 
     491  </tr> 
    451492 
    452493  <tr><td colspan="2" class="tog files"><h5><span><?php echo $files?'-':'+';?></span><?php echo _(' Additional Files')?><hr></h5></td></tr> 
     
    539580    <td><input type="checkbox" name="sudo"  tabindex="<?php echo ++$tabindex;?>" value="yes" <?php echo ($opts['sudo']=='yes')?'checked':''; ?> /></td> 
    540581  </tr> 
    541   <style type="text/css"> 
    542   tr .tog{cursor:pointer;} 
    543   tr .tog span{color:black} 
    544   <?php 
    545     $sections=array('files','ftp','ssh','email','remote','advanced'); 
    546     foreach($sections as $sec){ 
    547       if(!$$sec){echo '.hide.'.$sec.'{display:none}'."\n";} 
    548     } 
    549     if(!$advanced){echo '.advanced{display:none}'."\n";} 
    550   ?> 
    551   h5{margin-top:10px;margin-bottom:10px} 
    552   </style> 
    553   <script language="javascript" type="text/javascript"> 
    554     $(document).ready(function() { 
    555       $('.tog').click(function(){ 
    556         var tclass = $(this).attr('class'); tclass = tclass.replace('tog ', ''); 
    557         var togspan = $(this).find('span'); 
    558         if(togspan.text()=='+'){ 
    559           togspan.text('- '); 
    560           $('.'+tclass).show(); 
    561         }else{ 
    562           togspan.text('+'); 
    563           $('.'+tclass).not('.tog').hide(); 
    564         } 
    565        }); 
    566     }); 
    567   </script> 
    568582  <?php 
    569583} 
  • modules/branches/2.8/backup/install.php

    r9426 r9490  
    6868    emailmaxtype varchar(5), 
    6969    admin varchar(10), 
     70    overwritebackup varchar(5) default NULL, 
    7071    include blob, 
    7172    exclude blob, 
    7273    sudo varchar(25), 
    73     emotesshhost varchar(50) default NULL,  
     74    remotesshhost varchar(50) default NULL,  
    7475    remotesshuser varchar(50) default NULL,  
    7576    remotesshkey varchar(150) default NULL,  
     
    106107    emailmaxtype varchar(5), 
    107108    admin varchar(10), 
     109    overwritebackup varchar(5) default NULL, 
    108110    include blob, 
    109111    exclude blob, 
     
    236238} 
    237239 
    238 //check for 2.6-style table
     240//check remote backup field
    239241$sql='describe backup'; 
    240242$fields=$db->getAssoc($sql); 
     
    249251    out(_('WARNING: backup table not migrated')); 
    250252  } else { 
    251     out(_('Successfully migrated fax_incoming table!')); 
     253    out(_('Successfully migrated backup table!')); 
    252254  } 
    253255} 
    254256 
    255  
     257//check for overwritebackup filed 
     258$sql='describe backup'; 
     259$fields=$db->getAssoc($sql); 
     260if(!array_key_exists('overwritebackup',$fields)){ 
     261  out(_('Migrating backup table...')); 
     262  $sql='alter table backup add overwritebackup varchar(5) default NULL'; 
     263  $q=$db->query($sql); 
     264  if(DB::IsError($q)){ 
     265    out(_('WARNING: backup table not migrated')); 
     266  } else { 
     267    out(_('Successfully migrated backup table!')); 
     268  } 
     269
    256270?> 
  • modules/branches/2.8/backup/module.xml

    r9473 r9490  
    22  <rawname>backup</rawname> 
    33  <name>Backup &amp; Restore</name> 
    4   <version>2.8.0.2</version> 
     4  <version>2.8.0.3</version> 
    55  <publisher>FreePBX</publisher> 
    66  <license>GPLv2+</license> 
     
    1515  </depends> 
    1616  <changelog> 
     17    *2.8.0.3* #4167 
    1718    *2.8.0.2* #4167 
    1819    *2.8.0.1* #4167