<?php
$dbUser = 'xxx';               // db User
$dbPass = 'xxx';               // db User Password
$dbName = 'xxx';            // db name
$dest   = './backup'; // Path to directory                
 
class MySQLDump {
     /**
    * The backup command to execute
    * @private
    * @var string
    */
     var $cmd;
 
     /**
    * MySQLDump constructor
   * @param string dbUser (MySQL User Name)
    * @param string dbPass (MySQL User Password)
    * @param string dbName (Database to select)
    * @param string dest (Full destination directory path for backup file)
    * @access public
    */
     function MySQLDump ($dbUser,$dbPass,$dbName,$dest) {
             $fname = $dbName.'.xml';
             $this->cmd='mysqldump -X -u'.$dbUser.' -p'.$dbPass.' '.$dbName.
                 ' >'.$dest.'/'.$fname;
         }
 
 
     /**
    * Runs the constructed command
    * @access public
    * @return void
    */
     function backup () {
         system ($this->cmd, $error);
         if($error)
             trigger_error ('Backup failed: '.$error);
     }
}
 
// Instantiate MySQLDump
$mysqlDump = new MySQLDump($dbUser, $dbPass, $dbName, $dest);
 
// Perform the backup
$mysqlDump->backup();
 
?> 
  • info/mysqldump2xml.txt
  • Dernière modification: 2018/07/18 09:46
  • par radeff