These functions can backup, restore database in local win10.
public function dump($datetime) {
if (empty($datetime)) {
$datetime = date('YmdHis');
}
set_time_limit(0);
$drive = mb_substr(__DIR__, 0, 1, 'utf8');
$exe = $drive.':/xampp/mysql/bin/mysqldump --user='.DB_USERNAME.' --password='.DB_PASSWORD.' --host='.DB_HOSTNAME.' '.DB_DATABASE.' > '.
__DIR__.'/../_upload/sql/'.DB_DATABASE.$datetime.'.sql';
@exec($exe);
}
/**
* @param file __DIR__.'/../_upload/sql/'.DB_DATABASE.$datetime.'.sql'
*/
public function import($file) {
if (is_file($file)) {
set_time_limit(0);
$drive = mb_substr(__DIR__, 0, 1, 'utf8');
$exe = $drive.':/xampp/mysql/bin/mysql --user='.DB_USERNAME.' --password='.DB_PASSWORD.' '.DB_DATABASE.' < '. $file;
@exec($exe);
}
}
I want to backup database to the NAS so I replaced D:xampphtdocspj\_uploadsql
to ftp://user:[email protected]/pj/_upload/sql
in httpd-xampp.conf
but apache can't start.
Is there a way to soft link a ftp folder for php to read and write?
Alias /pj/_upload/sql "ftp://user:[email protected]/pj/_upload/sql/"
<Directory "ftp://user:[email protected]/pj/_upload/sql">
AllowOverride AuthConfig
Require all granted
</Directory>
question from:
https://stackoverflow.com/questions/65838717/backup-restore-database-from-neighbor 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…