[英]File is not writing mySQL backup CRON
我正在嘗試進行MySQL數據庫備份並保存.sql
文件。 該實用程序似乎處理得很好,但是在寫入文件時。 什么都沒發生。 不知道出什么問題了嗎? 路徑或代碼
public function mysql_backup()
{
// Load the DB utility class
$this->load->dbutil();
$date = new DateTime();
$time = $date->format('Y-m-d_H-i-s');
// Backup your entire database and assign it to a variable
$prefs = array(
'tables' => array(), // Array of tables to backup.
'ignore' => array(), // List of tables to omit from the backup
'format' => 'txt', // gzip, zip, txt
'filename' => 'sql_backup_'.$time.'.sql', // File name - NEEDED ONLY WITH ZIP FILES
'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
'add_insert' => TRUE, // Whether to add INSERT data to backup file
'newline' => "\n" // Newline character used in backup file
);
$backup = $this->dbutil->backup($prefs);
// Load the file helper and write the file to your server
write_file('./backup/sql_backup_'.$time.'.sql', $backup);
echo '<h2>Cron Successfully Runned.</h2>';
}
在我看來,您好像沒有加載file
助手。 嘗試添加$this->load->helper('file');
在代碼之前
public function mysql_backup()
{
// Load the DB utility class
$this->load->helper('file');
$this->load->dbutil();
$date = new DateTime();
$time = $date->format('Y-m-d_H-i-s');
// Backup your entire database and assign it to a variable
$prefs = array(
'tables' => array(), // Array of tables to backup.
'ignore' => array(), // List of tables to omit from the backup
'format' => 'txt', // gzip, zip, txt
'filename' => 'sql_backup_'.$time.'.sql', // File name - NEEDED ONLY WITH ZIP FILES
'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
'add_insert' => TRUE, // Whether to add INSERT data to backup file
'newline' => "\n" // Newline character used in backup file
);
$backup = $this->dbutil->backup($prefs);
// Load the file helper and write the file to your server
write_file('./backup/sql_backup_'.$time.'.sql', $backup);
echo '<h2>Cron Successfully Runned.</h2>';
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.