Commit 3aa4f475453dab2f87bd46e9be426c4f1d7a0837
1 parent
1369dd36
v1.29.3
- backup timeout megadható
Showing
2 changed files
with
27 additions
and
11 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
| @@ -1474,8 +1474,11 @@ GO | @@ -1474,8 +1474,11 @@ GO | ||
| 1474 | ColorConsole.WriteLine(backupfilename, ConsoleColor.Yellow, prefix: " backupfilename:"); | 1474 | ColorConsole.WriteLine(backupfilename, ConsoleColor.Yellow, prefix: " backupfilename:"); |
| 1475 | ColorConsole.WriteLine(backupFullName, ConsoleColor.Yellow, prefix: " backupFullName:"); | 1475 | ColorConsole.WriteLine(backupFullName, ConsoleColor.Yellow, prefix: " backupFullName:"); |
| 1476 | ColorConsole.WriteLine(createzip.ToString(), ConsoleColor.Yellow, prefix: " createzip:"); | 1476 | ColorConsole.WriteLine(createzip.ToString(), ConsoleColor.Yellow, prefix: " createzip:"); |
| 1477 | - ColorConsole.WriteLine(ZIPbackupfilename, ConsoleColor.Yellow, prefix: " ZIPbackupfilename:"); | ||
| 1478 | - ColorConsole.WriteLine(ZIPbackupFullName, ConsoleColor.Yellow, prefix: " ZIPbackupFullName:"); | 1477 | + if (createzip) |
| 1478 | + { | ||
| 1479 | + ColorConsole.WriteLine(ZIPbackupfilename, ConsoleColor.Yellow, prefix: " ZIPbackupfilename:"); | ||
| 1480 | + ColorConsole.WriteLine(ZIPbackupFullName, ConsoleColor.Yellow, prefix: " ZIPbackupFullName:"); | ||
| 1481 | + } | ||
| 1479 | ColorConsole.WriteLine(usetranzit.ToString(), ConsoleColor.Yellow, prefix: " usetranzit:"); | 1482 | ColorConsole.WriteLine(usetranzit.ToString(), ConsoleColor.Yellow, prefix: " usetranzit:"); |
| 1480 | ColorConsole.WriteLine(tranzitFullName, ConsoleColor.Yellow, prefix: " tranzitFullName:"); | 1483 | ColorConsole.WriteLine(tranzitFullName, ConsoleColor.Yellow, prefix: " tranzitFullName:"); |
| 1481 | ColorConsole.WriteLine(returnfilename, ConsoleColor.Yellow, prefix: " returnfilename:"); | 1484 | ColorConsole.WriteLine(returnfilename, ConsoleColor.Yellow, prefix: " returnfilename:"); |
| @@ -1507,11 +1510,19 @@ GO | @@ -1507,11 +1510,19 @@ GO | ||
| 1507 | try | 1510 | try |
| 1508 | { | 1511 | { |
| 1509 | sqlserver = SQLServerConnect(sqld.SQLCS, "master"); if (sqlserver == null) { return null; } | 1512 | sqlserver = SQLServerConnect(sqld.SQLCS, "master"); if (sqlserver == null) { return null; } |
| 1510 | - smoBackup.SqlBackupAsync(sqlserver); | ||
| 1511 | - var startbackup = DateTime.Now; | ||
| 1512 | - smoBackup.Wait(); | 1513 | + sqlserver.ConnectionContext.StatementTimeout = sqld.Xml_BackupTimeout; |
| 1514 | + backupstarttime = DateTime.Now; | ||
| 1515 | + smoBackup.SqlBackup(sqlserver); | ||
| 1516 | + //smoBackup.Wait(); | ||
| 1513 | Console.WriteLine($""); | 1517 | Console.WriteLine($""); |
| 1514 | - Console.WriteLine($"Backup completed. Backup time: {(int)(DateTime.Now.Subtract(startbackup).TotalSeconds)}sec."); | 1518 | + Console.WriteLine($"Backup completed. Backup time: {(int)(DateTime.Now.Subtract(backupstarttime).TotalSeconds)}sec."); |
| 1519 | + } | ||
| 1520 | + catch (Exception ex) | ||
| 1521 | + { | ||
| 1522 | + ColorConsole.WriteLine($"ERROR! Database backup failed. DB name:'{smoBackup.Database}'. BAK/ZIP file name:'{Path.GetFileName(returnfilename)}'", ConsoleColor.Red); | ||
| 1523 | + var errmsg = ""; while (ex != null) { errmsg += ";" + ex.Message;ex = ex.InnerException; } | ||
| 1524 | + ColorConsole.WriteLine(errmsg, ConsoleColor.Red); | ||
| 1525 | + return null; | ||
| 1515 | } | 1526 | } |
| 1516 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } | 1527 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } |
| 1517 | if (usetranzit && File.Exists(tranzitFullName)) | 1528 | if (usetranzit && File.Exists(tranzitFullName)) |
| @@ -1539,14 +1550,14 @@ GO | @@ -1539,14 +1550,14 @@ GO | ||
| 1539 | } | 1550 | } |
| 1540 | return returnfilename; | 1551 | return returnfilename; |
| 1541 | } | 1552 | } |
| 1542 | - | 1553 | + private static DateTime backupstarttime; |
| 1543 | private static void SmoBackupRestore_PercentComplete(object sender, PercentCompleteEventArgs e) | 1554 | private static void SmoBackupRestore_PercentComplete(object sender, PercentCompleteEventArgs e) |
| 1544 | { | 1555 | { |
| 1545 | ColorConsole.SetCursorPosition(0, Console.CursorTop); | 1556 | ColorConsole.SetCursorPosition(0, Console.CursorTop); |
| 1546 | - ColorConsole.Write($"Completed: {e.Percent}%. {e.Message}"); | 1557 | + ColorConsole.Write($"Completed: {e.Percent}%. {e.Message}. Backup time : {(int)(DateTime.Now.Subtract(backupstarttime).TotalSeconds)}sec."); |
| 1547 | } | 1558 | } |
| 1548 | 1559 | ||
| 1549 | - public static List<FileInfo> GetBackupFilePathList(SQLDataBase sqld) | 1560 | + public static List<FileInfo> GetBackupFilePathList(SQLDataBase sqld) |
| 1550 | { | 1561 | { |
| 1551 | var filenamemask = Path.GetFileNameWithoutExtension(sqld.Xml_BackupFileNameMask); | 1562 | var filenamemask = Path.GetFileNameWithoutExtension(sqld.Xml_BackupFileNameMask); |
| 1552 | var vars = new Dictionary<string, string>(); | 1563 | var vars = new Dictionary<string, string>(); |
| @@ -2313,6 +2324,7 @@ GO | @@ -2313,6 +2324,7 @@ GO | ||
| 2313 | Xml_TranzitDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath.Values.DEFAULT), | 2324 | Xml_TranzitDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath.Values.DEFAULT), |
| 2314 | Xml_PhysicalFilesDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath.Values.DEFAULT), | 2325 | Xml_PhysicalFilesDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath.Values.DEFAULT), |
| 2315 | Xml_ScriptCommandTimeout = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout), this.RootElement, SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout.Values.DEFAULT), | 2326 | Xml_ScriptCommandTimeout = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout), this.RootElement, SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout.Values.DEFAULT), |
| 2327 | + Xml_BackupTimeout = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.BackupTimeout), this.RootElement, SQLDataBase.XmlStructure.Attributes.BackupTimeout.Values.DEFAULT), | ||
| 2316 | }; | 2328 | }; |
| 2317 | var sqldatabasexmllist = GetAllXElements(nameof(SQLDataBase.XmlStructure.SQLDataBase)); | 2329 | var sqldatabasexmllist = GetAllXElements(nameof(SQLDataBase.XmlStructure.SQLDataBase)); |
| 2318 | if (sqldatabasexmllist != null && sqldatabasexmllist.Any()) | 2330 | if (sqldatabasexmllist != null && sqldatabasexmllist.Any()) |
| @@ -2343,6 +2355,7 @@ GO | @@ -2343,6 +2355,7 @@ GO | ||
| 2343 | public string Xml_SQLConnectionString; | 2355 | public string Xml_SQLConnectionString; |
| 2344 | public string Xml_PhysicalFilesDirectoryPath; | 2356 | public string Xml_PhysicalFilesDirectoryPath; |
| 2345 | public int Xml_ScriptCommandTimeout; | 2357 | public int Xml_ScriptCommandTimeout; |
| 2358 | + public int Xml_BackupTimeout; | ||
| 2346 | public List<SQLData> Xml_SQLDataList; | 2359 | public List<SQLData> Xml_SQLDataList; |
| 2347 | public List<LastUpdatedTrigger> Xml_SQLLastUpdatedTriggerList; | 2360 | public List<LastUpdatedTrigger> Xml_SQLLastUpdatedTriggerList; |
| 2348 | public List<DBUser> Xml_SQLDbUserList; | 2361 | public List<DBUser> Xml_SQLDbUserList; |
| @@ -2460,6 +2473,7 @@ GO | @@ -2460,6 +2473,7 @@ GO | ||
| 2460 | Xml_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.PhysicalFilesDirectoryPath), sqldatabasexml, common.Xml_PhysicalFilesDirectoryPath); | 2473 | Xml_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.PhysicalFilesDirectoryPath), sqldatabasexml, common.Xml_PhysicalFilesDirectoryPath); |
| 2461 | 2474 | ||
| 2462 | Xml_ScriptCommandTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.ScriptCommandTimeout), sqldatabasexml, common.Xml_ScriptCommandTimeout); | 2475 | Xml_ScriptCommandTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.ScriptCommandTimeout), sqldatabasexml, common.Xml_ScriptCommandTimeout); |
| 2476 | + Xml_BackupTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTimeout), sqldatabasexml, common.Xml_BackupTimeout); | ||
| 2463 | 2477 | ||
| 2464 | Xml_SQLDataList = new List<SQLData>(); | 2478 | Xml_SQLDataList = new List<SQLData>(); |
| 2465 | var sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); | 2479 | var sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); |
| @@ -2515,6 +2529,7 @@ GO | @@ -2515,6 +2529,7 @@ GO | ||
| 2515 | public static class PhysicalFilesDirectoryPath { public static class Values { public const string DEFAULT = ""; } } | 2529 | public static class PhysicalFilesDirectoryPath { public static class Values { public const string DEFAULT = ""; } } |
| 2516 | public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } | 2530 | public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } |
| 2517 | 2531 | ||
| 2532 | + public static class BackupTimeout { public static class Values { public const int DEFAULT = 10000; } } | ||
| 2518 | 2533 | ||
| 2519 | public static class CreateZip{ public static class Values { public const bool DEFAULT = true; } } | 2534 | public static class CreateZip{ public static class Values { public const bool DEFAULT = true; } } |
| 2520 | } | 2535 | } |
| @@ -2532,6 +2547,7 @@ GO | @@ -2532,6 +2547,7 @@ GO | ||
| 2532 | public static class CreateZip { } | 2547 | public static class CreateZip { } |
| 2533 | public static class PhysicalFilesDirectoryPath { } | 2548 | public static class PhysicalFilesDirectoryPath { } |
| 2534 | public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } | 2549 | public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } |
| 2550 | + public static class BackupTimeout { public static class Values { public const int DEFAULT = 10000; } } | ||
| 2535 | } | 2551 | } |
| 2536 | public static class SQLData | 2552 | public static class SQLData |
| 2537 | { | 2553 | { |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
| @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
| 32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
| 33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
| 34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
| 35 | -[assembly: AssemblyVersion("1.29.2.0")] | ||
| 36 | -[assembly: AssemblyFileVersion("1.29.2.0")] | 35 | +[assembly: AssemblyVersion("1.29.3.0")] |
| 36 | +[assembly: AssemblyFileVersion("1.29.3.0")] |