Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 20b0d95

Browse files
authoredMar 4, 2023
Backup Restore
1 parent 4b77def commit 20b0d95

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎restore.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
preg_match("/define\(\s*'DB_HOST',\s*'(.+)'\s*\);/", $old_config, $db_host_match);
2222

2323
// Update wp-config.php with database details
24-
$config_file = file_get_contents('old-wp-config.php');
24+
$config_file = file_get_contents('wp-config.php');
2525
$config_file = preg_replace("/define\(\s*'DB_NAME',\s*'(.+)'\s*\);/", "define('DB_NAME', '{$db_name_match[1]}');", $config_file);
2626
$config_file = preg_replace("/define\(\s*'DB_USER',\s*'(.+)'\s*\);/", "define('DB_USER', '{$db_user_match[1]}');", $config_file);
2727
$config_file = preg_replace("/define\(\s*'DB_PASSWORD',\s*'(.+)'\s*\);/", "define('DB_PASSWORD', '{$db_password_match[1]}');", $config_file);
@@ -37,8 +37,7 @@
3737
$sql_file = shell_exec('ls backup-wp-db-*.sql');
3838
$import_cmd = "mysql -u {$db_user_match[1]} -p{$db_password_match[1]} -h {$db_host_match[1]} {$db_name_match[1]} < {$sql_file} 2>&1";
3939
$import_output = shell_exec($import_cmd);
40-
file_put_contents($log_file, "Import Command Output: \n{$import_output}\n\n", FILE_APPEND);
41-
40+
file_put_contents($log_file, "Database has been imported. Please ingore MySQL insecure password warning. \n{$import_output}\n\n", FILE_APPEND);
4241

4342
// Log execution
4443
$timestamp = date('Y-m-d H:i:s');

0 commit comments

Comments
 (0)
Please sign in to comment.