Answer the question
In order to leave comments, you need to log in
How to make a database backup with PHP?
<?php
$backup_folder = '/www/site.ru/backup'; // куда сохранятся файлы - полный путь ИЛИ /backup
$backup_name = 'datebase_backup_' . date("Y-m-d"); // имя нового файла
$db_host = 'localhost';
$db_user = 'petuh';
$db_password = '12345';
$db_name = 'petuh';
function backupDB($backup_folder, $backup_name){
global $db_host;
global $db_user;
global $db_password;
global $db_name;
$fullFileName = $backup_folder . '/' . $backup_name . '.sql';
$command = 'mysqldump -h' . $db_host . ' -u' . $db_user . ' -p' . $db_password . ' ' . $db_name . ' > ' . $fullFileName;
shell_exec($command);
return $fullFileName;
}
backupDB($backup_folder, $backup_name);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question