auto_backup.php 704 B

1234567891011121314151617181920
  1. <?php
  2. chdir(dirname(__FILE__));
  3. require_once 'config.php';
  4. require_once 'function.php';
  5. $mysqldump = 'mysqldump';
  6. $opt = ' --no-defaults --add-drop-table ';
  7. // $opt .= ' --compatible=no_table_options,mysql323 ';
  8. //$opt .= ' --compact ';
  9. $optAuth = ' -h '.$adodb_host.' -u '.$adodb_user.' --password='.$adodb_pass.' '.$adodb_db;
  10. $outFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'backup'.DIRECTORY_SEPARATOR.$adodb_db.'_'.date('Y-m-d').'.sql';
  11. $outFile = escapeshellarg($outFile);
  12. openLogger(basename(__FILE__));
  13. $logger->info($mysqldump.$opt.$optAuth.' > '.$outFile);
  14. $output = shell_exec($mysqldump.$opt.$optAuth.' > '.$outFile);
  15. //if ($output) $logger->info($output);
  16. closeLogger();
  17. ?>