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 | 1474 | ColorConsole.WriteLine(backupfilename, ConsoleColor.Yellow, prefix: " backupfilename:"); |
1475 | 1475 | ColorConsole.WriteLine(backupFullName, ConsoleColor.Yellow, prefix: " backupFullName:"); |
1476 | 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 | 1482 | ColorConsole.WriteLine(usetranzit.ToString(), ConsoleColor.Yellow, prefix: " usetranzit:"); |
1480 | 1483 | ColorConsole.WriteLine(tranzitFullName, ConsoleColor.Yellow, prefix: " tranzitFullName:"); |
1481 | 1484 | ColorConsole.WriteLine(returnfilename, ConsoleColor.Yellow, prefix: " returnfilename:"); |
... | ... | @@ -1507,11 +1510,19 @@ GO |
1507 | 1510 | try |
1508 | 1511 | { |
1509 | 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 | 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 | 1527 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } |
1517 | 1528 | if (usetranzit && File.Exists(tranzitFullName)) |
... | ... | @@ -1539,14 +1550,14 @@ GO |
1539 | 1550 | } |
1540 | 1551 | return returnfilename; |
1541 | 1552 | } |
1542 | - | |
1553 | + private static DateTime backupstarttime; | |
1543 | 1554 | private static void SmoBackupRestore_PercentComplete(object sender, PercentCompleteEventArgs e) |
1544 | 1555 | { |
1545 | 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 | 1562 | var filenamemask = Path.GetFileNameWithoutExtension(sqld.Xml_BackupFileNameMask); |
1552 | 1563 | var vars = new Dictionary<string, string>(); |
... | ... | @@ -2313,6 +2324,7 @@ GO |
2313 | 2324 | Xml_TranzitDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath.Values.DEFAULT), |
2314 | 2325 | Xml_PhysicalFilesDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath.Values.DEFAULT), |
2315 | 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 | 2329 | var sqldatabasexmllist = GetAllXElements(nameof(SQLDataBase.XmlStructure.SQLDataBase)); |
2318 | 2330 | if (sqldatabasexmllist != null && sqldatabasexmllist.Any()) |
... | ... | @@ -2343,6 +2355,7 @@ GO |
2343 | 2355 | public string Xml_SQLConnectionString; |
2344 | 2356 | public string Xml_PhysicalFilesDirectoryPath; |
2345 | 2357 | public int Xml_ScriptCommandTimeout; |
2358 | + public int Xml_BackupTimeout; | |
2346 | 2359 | public List<SQLData> Xml_SQLDataList; |
2347 | 2360 | public List<LastUpdatedTrigger> Xml_SQLLastUpdatedTriggerList; |
2348 | 2361 | public List<DBUser> Xml_SQLDbUserList; |
... | ... | @@ -2460,6 +2473,7 @@ GO |
2460 | 2473 | Xml_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.PhysicalFilesDirectoryPath), sqldatabasexml, common.Xml_PhysicalFilesDirectoryPath); |
2461 | 2474 | |
2462 | 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 | 2478 | Xml_SQLDataList = new List<SQLData>(); |
2465 | 2479 | var sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); |
... | ... | @@ -2515,6 +2529,7 @@ GO |
2515 | 2529 | public static class PhysicalFilesDirectoryPath { public static class Values { public const string DEFAULT = ""; } } |
2516 | 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 | 2534 | public static class CreateZip{ public static class Values { public const bool DEFAULT = true; } } |
2520 | 2535 | } |
... | ... | @@ -2532,6 +2547,7 @@ GO |
2532 | 2547 | public static class CreateZip { } |
2533 | 2548 | public static class PhysicalFilesDirectoryPath { } |
2534 | 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 | 2552 | public static class SQLData |
2537 | 2553 | { | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
... | ... | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; |
32 | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
33 | 33 | // by using the '*' as shown below: |
34 | 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")] | ... | ... |