Aggiunti esempi e conf x testare opzioni export/import
This commit is contained in:
@@ -78,10 +78,16 @@ namespace EgtBEAMWALL.DataLayer
|
||||
/// </summary>
|
||||
/// <param name="outFilePath">Percorso di salvataggio del dump (*.sql)</param>
|
||||
/// <param name="mysqlDumpPath">Nome o Percorso Eseguibile mysqldump (opzionale)</param>
|
||||
/// <param name="exportOpt">Opzioni in fase di export (default: --skip-extended-insert)</param>
|
||||
/// <returns></returns>
|
||||
public static bool DataBaseDumpToFile(string outFilePath, string mysqlDumpPath = "mysqldump")
|
||||
public static bool DataBaseDumpToFile(string outFilePath, string mysqlDumpPath = "mysqldump", string exportOpt = "--skip-extended-insert")
|
||||
{
|
||||
bool fatto = false;
|
||||
// fix path eseguibile
|
||||
if (string.IsNullOrEmpty(mysqlDumpPath))
|
||||
{
|
||||
mysqlDumpPath = "mysqldump";
|
||||
}
|
||||
// aggiungo sql finale
|
||||
if (!outFilePath.EndsWith(".sql"))
|
||||
{
|
||||
@@ -99,7 +105,7 @@ namespace EgtBEAMWALL.DataLayer
|
||||
File.Delete(outFilePath);
|
||||
}
|
||||
// chiamo script esterno... importante parametro "--skip-extended-insert" altrimenti problemi con restore (anche se + verboso e lento in backup...)
|
||||
string callScript = $"\"{mysqlDumpPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {DATABASE_NAME} --skip-extended-insert > {outFilePath}";
|
||||
string callScript = $"\"{mysqlDumpPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {DATABASE_NAME} {exportOpt} > {outFilePath}";
|
||||
ExecuteCommand(callScript);
|
||||
return fatto;
|
||||
}
|
||||
@@ -109,17 +115,23 @@ namespace EgtBEAMWALL.DataLayer
|
||||
/// </summary>
|
||||
/// <param name="inFilePath">Percorso di lettura del dump (*.sql)</param>
|
||||
/// <param name="mysqlPath">Nome o Percorso Eseguibile mysql (opzionale)</param>
|
||||
/// <param name="importOpt">Opzioni in fase di import (default: --force)</param>
|
||||
/// <returns></returns>
|
||||
public static bool DataBaseRestoreFromFile(string inFilePath, string mysqlPath="mysql")
|
||||
public static bool DataBaseRestoreFromFile(string inFilePath, string mysqlPath = "mysql", string importOpt = "--force")
|
||||
{
|
||||
bool fatto = false;
|
||||
// fix path eseguibile
|
||||
if (string.IsNullOrEmpty(mysqlPath))
|
||||
{
|
||||
mysqlPath = "mysql";
|
||||
}
|
||||
// aggiungo sql finale
|
||||
if (!inFilePath.EndsWith(".sql"))
|
||||
{
|
||||
inFilePath = $"{inFilePath}.sql";
|
||||
}
|
||||
// chiamo script esterno...
|
||||
string callScript = $"\"{mysqlPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {DATABASE_NAME} < {inFilePath}";
|
||||
string callScript = $"\"{mysqlPath}\" -u{DATABASE_USER} -p{DATABASE_PWD} {importOpt} {DATABASE_NAME} < {inFilePath}";
|
||||
ExecuteCommand(callScript);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace EgtBEAMWALL.StressTest
|
||||
{
|
||||
// effettua dump
|
||||
//DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump");
|
||||
//DataLayer.DbConfig.DataBaseDumpToFile(outPath, "mysqldump", "--skip-extended-insert");
|
||||
DataLayer.DbConfig.DataBaseDumpToFile(outPath);
|
||||
sw.Stop();
|
||||
var elapsed = sw.Elapsed;
|
||||
@@ -79,14 +80,14 @@ namespace EgtBEAMWALL.StressTest
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
labelResult.Text = "...";
|
||||
string inPath = txtDumpFile.Text.Trim();
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// effettua restore
|
||||
DataLayer.DbConfig.DataBaseRestoreFromFile(inPath); sw.Stop();
|
||||
//string binPath = "C:\\Program Files\\MariaDB 10.5\\bin";
|
||||
//string mysqlPath = Path.Combine(binPath, "mysql.exe");
|
||||
string inPath = txtDumpFile.Text.Trim();
|
||||
// effettua restore
|
||||
//DataLayer.DbConfig.DataBaseRestoreFromFile(inPath, "mysql");
|
||||
DataLayer.DbConfig.DataBaseRestoreFromFile(inPath); sw.Stop();
|
||||
var elapsed = sw.Elapsed;
|
||||
labelResult.Text = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} | Restore Done in {elapsed.TotalSeconds:N3} sec!";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user