数据库数组变量是:
$_CONFIG['db_databases'] = array( // Datenbanken
'acc' => 'ACCOUNT_DBF',
'chr' => 'CHARACTER_01_DBF',
'web' => 'WEBSITE_DBF',
'log' => 'LOGGING_01_DBF',
'eocrm' => 'EoCRM_DBF',
'eocrm_r' => 'EoCRM_DBF_R',
'itm' => 'ITEM_DBF',
'mng' => 'MANAGE_DBF',
'rnk' => 'RANKING_DBF',
);
路径变量是:
$_CONFIG['db_backup_path'] = 'C:\xampp\htdocs\extras\Backups - Database';
所以这是我的备份函数的完整代码,它循环遍历数组'db_databases'中的每个数据库。
foreach($_CONFIG['db_databases'] as $type => $strNameOfDatabase) {
if($type != 'log') {
if(@odbc_exec($odbc_connect, "
BACKUP DATABASE [$strNameOfDatabase]
TO DISK = '" . $_CONFIG['db_backup_path'] . "\\" . date('Y') . "\\" . date('m') . "\\$date-$strNameOfDatabase.bak'
WITH NOFORMAT, NOINIT, NAME = N'$strNameOfDatabase - Full Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
")) {
$notifyArray[] = "Success: Back up of [$strNameOfDatabase]";
}
else {
$notifyArray[] = "Error: Back up of [$strNameOfDatabase]";
}
}
}
我不知道为什么不做这项工作。我试图手动执行相同的脚本到我的mssql 2014,它执行并备份数据库。路径有什么不对吗?