Alpha Framework alpha--util
[ class tree: alpha--util ] [ index: alpha--util ] [ all elements ]

Source for file AlphaBackupUtils.inc

Documentation is available at AlphaBackupUtils.inc

  1. <?php
  2.  
  3. require_once $config->get('sysRoot').'alpha/util/AlphaFileUtils.inc';
  4.  
  5. /**
  6.  * A utility class for carrying out various backup tasks
  7.  * 
  8.  * @package alpha::util
  9.  * @since 1.1
  10.  * @author John Collins <dev@alphaframework.org>
  11.  * @version $Id: AlphaBackupUtils.inc 1455 2011-12-04 15:26:05Z johnc $
  12.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  13.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  14.  *  All rights reserved.
  15.  * 
  16.  *  <pre>
  17.  *  Redistribution and use in source and binary forms, with or
  18.  *  without modification, are permitted provided that the
  19.  *  following conditions are met:
  20.  * 
  21.  *  * Redistributions of source code must retain the above
  22.  *    copyright notice, this list of conditions and the
  23.  *    following disclaimer.
  24.  *  * Redistributions in binary form must reproduce the above
  25.  *    copyright notice, this list of conditions and the
  26.  *    following disclaimer in the documentation and/or other
  27.  *    materials provided with the distribution.
  28.  *  * Neither the name of the Alpha Framework nor the names
  29.  *    of its contributors may be used to endorse or promote
  30.  *    products derived from this software without specific
  31.  *    prior written permission.
  32.  *   
  33.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  34.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  35.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  36.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  37.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  38.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  39.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  40.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  41.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  42.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  43.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  44.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  45.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46.  *  </pre>
  47.  *  
  48.  */
  49.     /**
  50.      * Backs up the attachments and logs directories to the destination backup directory
  51.      * 
  52.      * @param string $backupDir 
  53.      * @since 1.1
  54.      */
  55.     public static function backUpAttachmentsAndLogs($backupDir{
  56.         global $config;
  57.  
  58.         AlphaFileUtils::copy($config->get('sysRoot').'attachments'$backupDir.'attachments');
  59.         AlphaFileUtils::copy($config->get('sysRoot').'logs'$backupDir.'logs');
  60.     }
  61.     
  62.     /**
  63.      * Uses the mysqldump command line program to back-up the system database into an .sql file in the supplied target directory
  64.      * 
  65.      * @param string $backupDir The directory where we will write the .sql back-up file
  66.      * @since 1.1
  67.      */
  68.     public static function backUpDatabase($backupDir{
  69.         global $config;
  70.         
  71.         $targetFileName $backupDir.$config->get('sysDB').'_'.date("d-m-Y").'.sql';
  72.         
  73.         exec('mysqldump  --host="'.$config->get('sysDBHost').'" --user="'.$config->get('sysDBUsername').'" --password="'.$config->get('sysDBPassword').'" --opt '.$config->get('sysDB').' 2>&1 >'.$targetFileName);
  74.     }
  75. }
  76.  
  77. ?>

Documentation generated on Tue, 13 Dec 2011 20:25:30 +0000 by phpDocumentor 1.4.3