"When I backup the database on the server in production, it's impossible to use this backup to restore the database on my local computer" - are you using the same mariadb version on your local computer?
Aug 20, 2024
3
Level 63
What's wrong with my code with ZipArchive protected with a password ?
Hello,
I encounter some problems with this code to unzip an archive protected by a password and use the unzipped SQL file to restore the database.
if ($zip->open($archiveFullpath) === true) {
if ($zip->setPassword($password)) {
if ($zip->extractTo($this->pathForBackup)) {
Artisan::call('migrate:fresh');
$command = 'mysql';
$command .= ' --host='.config('database.connections.mariadb.host');
$command .= ' --user='.config('database.connections.mariadb.username');
$command .= ' --password='.config('database.connections.mariadb.password');
$command .= ' '.config('database.connections.mariadb.database').' < '.$fileFullpath;
$process = Process::run($command);
if (!$process->successful()) {
Log::warning('Failed to restore the database');
$code = 500;
}
session(['database_in_maintenance' => false]);
unlink($fileFullpath);
} else {
...
}
} else {
...
}
$zip->close();
unlink($archiveFullpath);
} else {
...
}
When I backup the database on the server in production, it's impossible to use this backup to restore the database on my local computer.
I have logged the errorOutput of the process and I read this error.
ERROR at line 1: Unknown command '\-'..
When I have a look at the SQL file, I find this first line where you can see the \- characters.
/*!999999\- enable the sandbox mode */
But it's a comment.
How can I avoid this problem ?
Thanks for your help.
V
Level 14
1 like
Please or to participate in this conversation.