mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-23 00:45:36 +00:00
Merge pull request #4967 from Dokploy/fix/restore-drop-use-statements
fix(restore): drop USE/CREATE DATABASE statements so mysql/mariadb restores target the selected database
(cherry picked from commit ce0fe63b4a)
[skip ci]
This commit is contained in:
committed by
Dokploy Bot
parent
19958ee9d9
commit
2003886aa0
@@ -79,6 +79,10 @@ const generateRestoreCommand = (
|
||||
}
|
||||
};
|
||||
|
||||
// Dumps taken with `--databases` carry `USE`/`CREATE DATABASE` statements that
|
||||
// would redirect the restore away from the database selected in the dialog.
|
||||
export const stripDatabaseSwitchCommand = `grep -viE '^[[:space:]]*(use|create[[:space:]]+database)[[:space:]]'`;
|
||||
|
||||
const getMongoSpecificCommand = (
|
||||
rcloneCommand: string,
|
||||
restoreCommand: string,
|
||||
@@ -125,7 +129,9 @@ export const getRestoreCommand = ({
|
||||
const restoreCommand = generateRestoreCommand(type, credentials);
|
||||
let cmd = `CONTAINER_ID=$(${containerSearch})`;
|
||||
|
||||
if (type !== "mongo") {
|
||||
if (type === "mysql" || type === "mariadb") {
|
||||
cmd += ` && ${rcloneCommand} | ${stripDatabaseSwitchCommand} | ${restoreCommand}`;
|
||||
} else if (type !== "mongo") {
|
||||
cmd += ` && ${rcloneCommand} | ${restoreCommand}`;
|
||||
} else {
|
||||
cmd += ` && ${getMongoSpecificCommand(rcloneCommand, restoreCommand, backupFile || "")}`;
|
||||
|
||||
Reference in New Issue
Block a user