Commit fb6819fe14886514436fc020450ba7ab0983762f
1 parent
acc7abda
v1.2.4.0
- Backup temp directory helye megadható
Showing
2 changed files
with
55 additions
and
44 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
@@ -86,21 +86,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -86,21 +86,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
86 | 86 | ||
87 | var destinationfilename = Path.GetFileNameWithoutExtension(bp.Xml_PackageFilePath); | 87 | var destinationfilename = Path.GetFileNameWithoutExtension(bp.Xml_PackageFilePath); |
88 | //string tempfolderpath = Tools.GetTemporaryFoldername(destinationfolder); | 88 | //string tempfolderpath = Tools.GetTemporaryFoldername(destinationfolder); |
89 | - string tempfolderpath = StringConstructor.ResolveConstructor(vars, Path.Combine(destinationfolder,destinationfilename), "{}@@"); | ||
90 | - if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath, true); } | ||
91 | 89 | ||
90 | + destinationfilename = StringConstructor.ResolveConstructor(vars, destinationfilename, "{}@@"); | ||
91 | + destinationfolder = StringConstructor.ResolveConstructor(vars, destinationfolder, "{}@@"); | ||
92 | + var temprootfolder=string.IsNullOrEmpty(bp.Xml_TempDirectoryPath) ? destinationfolder : bp.Xml_TempDirectoryPath; | ||
93 | + | ||
94 | + string tempfolderpath = Path.Combine(temprootfolder, destinationfilename); | ||
95 | + | ||
96 | + if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath, true); } | ||
92 | if (!Directory.Exists(tempfolderpath)) { Directory.CreateDirectory(tempfolderpath); } | 97 | if (!Directory.Exists(tempfolderpath)) { Directory.CreateDirectory(tempfolderpath); } |
93 | 98 | ||
94 | - foreach (var bf in bp.Xml_BackupFolderList) | ||
95 | - { | ||
96 | - BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath, vars); | ||
97 | - } | ||
98 | - foreach (var sqldb in bp.Xml_BackupSQLDataBaseList) | ||
99 | - { | ||
100 | - SQLDataBaseManagerNS.SQLDataBaseManager.Execute(sqldb.Xml_Key,sqldb.Xml_DBBackup,sqldb.Xml_ScriptBackup,sqldb.Xml_TableDataBackup, tempfolderpath, timestamp); | ||
101 | - } | 99 | + foreach (var bf in bp.Xml_BackupFolderList) { BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath, vars); } |
100 | + foreach (var sqldb in bp.Xml_BackupSQLDataBaseList) { SQLDataBaseManagerNS.SQLDataBaseManager.Execute(sqldb.Xml_Key,sqldb.Xml_DBBackup,sqldb.Xml_ScriptBackup,sqldb.Xml_TableDataBackup, tempfolderpath, timestamp); } | ||
102 | 101 | ||
103 | - BackupPackageManagerCore.CreatePackageFile(bp, tempfolderpath, vars); | 102 | + BackupPackageManagerCore.CreatePackageFile(bp.Xml_PackageName, tempfolderpath, vars, destinationfilename,destinationfolder, bp.Xml_CreateExe, bp.Xml_SourceIncludeFilenameMaskList); |
104 | if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath,true); } | 103 | if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath,true); } |
105 | } | 104 | } |
106 | catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } | 105 | catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } |
@@ -210,21 +209,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -210,21 +209,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
210 | /// Create package compressed file | 209 | /// Create package compressed file |
211 | /// </summary> | 210 | /// </summary> |
212 | /// <param name="bp">package descriptor</param> | 211 | /// <param name="bp">package descriptor</param> |
213 | - /// <param name="sourcedirectorypath">source directory, where the package content files are located; | ||
214 | - /// the package file will be created with the same name with zip or exe extension in its parent directory</param> | 212 | + /// <param name="sourcedirectorypath">source directory, where the package content files are located</param> |
213 | + /// <param name="destinationfolder">the folder to store the created package file; if null the package file will be created in the parent directory of sourcedirectorypath</param> | ||
214 | + /// <param name="destinationfilename ">the name of the package file; if null the package file name will be the same as the "last" directory name in sourcedirectorypath</param> | ||
215 | /// <param name="vars">substitution vars</param> | 215 | /// <param name="vars">substitution vars</param> |
216 | - public static void CreatePackageFile(BackupPackage bp,string sourcedirectorypath, Dictionary<string,string> vars) | 216 | + /// <param name="createexe">if true, exe self extractor will be created, otherwise zip file; the extension of the package file is zip or exe</param> |
217 | + /// <param name="sourceincludefilenamemaskList">comma separated list of masks for the files to include (NOT regex! "old fashioned" masking characters, like ?/* can be used)</param> | ||
218 | + public static void CreatePackageFile(string packagename,string sourcedirectorypath, Dictionary<string,string> vars,string destinationfilename =null,string destinationfolder=null,bool createexe=true,string sourceincludefilenamemaskList=null) | ||
217 | { | 219 | { |
218 | - string[] sourceincludefilenamemasklist = bp.Xml_SourceIncludeFilenameMaskList.Split(','); | ||
219 | - bool createselfextractor = bp.Xml_CreateExe; | 220 | + string[] sourceinclfnamemasklist = sourceincludefilenamemaskList.Split(','); |
221 | + bool createselfextractor = createexe; | ||
220 | 222 | ||
221 | if (!Path.IsPathRooted(sourcedirectorypath)) { sourcedirectorypath = Path.Combine(Directory.GetCurrentDirectory(), sourcedirectorypath); } | 223 | if (!Path.IsPathRooted(sourcedirectorypath)) { sourcedirectorypath = Path.Combine(Directory.GetCurrentDirectory(), sourcedirectorypath); } |
222 | 224 | ||
223 | - var destinationfolder = Path.GetDirectoryName(sourcedirectorypath); | 225 | + destinationfolder = destinationfolder??Path.GetDirectoryName(sourcedirectorypath); |
224 | if (!Path.IsPathRooted(destinationfolder)) { destinationfolder = Path.Combine(Directory.GetCurrentDirectory(), destinationfolder); } | 226 | if (!Path.IsPathRooted(destinationfolder)) { destinationfolder = Path.Combine(Directory.GetCurrentDirectory(), destinationfolder); } |
225 | - var destinationfile = Path.GetFileNameWithoutExtension(sourcedirectorypath); | 227 | + destinationfilename = destinationfilename??Path.GetFileNameWithoutExtension(sourcedirectorypath); |
226 | 228 | ||
227 | - string package___filepath = Path.Combine(destinationfolder, destinationfile); | 229 | + string package___filepath = Path.Combine(destinationfolder, destinationfilename); |
228 | package___filepath=VRH.Common.StringConstructor.ResolveConstructor(vars, package___filepath, "{}@@"); | 230 | package___filepath=VRH.Common.StringConstructor.ResolveConstructor(vars, package___filepath, "{}@@"); |
229 | 231 | ||
230 | string packageEXEfilepath = package___filepath + ".exe"; | 232 | string packageEXEfilepath = package___filepath + ".exe"; |
@@ -233,7 +235,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -233,7 +235,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
233 | if (File.Exists(packageZIPfilepath)) { File.Delete(packageZIPfilepath); } | 235 | if (File.Exists(packageZIPfilepath)) { File.Delete(packageZIPfilepath); } |
234 | 236 | ||
235 | List<string> includefilepathlist = new List<string>(); | 237 | List<string> includefilepathlist = new List<string>(); |
236 | - foreach (var includefilenamemask in sourceincludefilenamemasklist) { includefilepathlist.Add(Path.Combine(sourcedirectorypath, includefilenamemask)); } | 238 | + foreach (var includefilenamemask in sourceinclfnamemasklist) { includefilepathlist.Add(Path.Combine(sourcedirectorypath, includefilenamemask)); } |
237 | 239 | ||
238 | string includeliststr = String.Join(" ", includefilepathlist.ToArray()); | 240 | string includeliststr = String.Join(" ", includefilepathlist.ToArray()); |
239 | string recursesubdirs = "-r"; | 241 | string recursesubdirs = "-r"; |
@@ -253,7 +255,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -253,7 +255,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
253 | packagefile = packageZIPfilepath; | 255 | packagefile = packageZIPfilepath; |
254 | response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {archivetype_zip}"); | 256 | response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {archivetype_zip}"); |
255 | } | 257 | } |
256 | - ColorConsole.WriteLine($"Backup package created. Package name:{bp.Xml_PackageName}, package file: {packagefile}", ConsoleColor.Green); | 258 | + ColorConsole.WriteLine($"Backup package created. Package name:{packagename}, package file: {packagefile}", ConsoleColor.Green); |
257 | 259 | ||
258 | 260 | ||
259 | // 7 - Zip[64] 16.04 : Copyright(c) 1999 - 2016 Igor Pavlov : 2016 - 10 - 04 | 261 | // 7 - Zip[64] 16.04 : Copyright(c) 1999 - 2016 Igor Pavlov : 2016 - 10 - 04 |
@@ -334,10 +336,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -334,10 +336,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
334 | public BackupPackageManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) | 336 | public BackupPackageManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) |
335 | { | 337 | { |
336 | _backuppackagelist = new List<BackupPackage>(); | 338 | _backuppackagelist = new List<BackupPackage>(); |
339 | + var tmpdirpath = GetValue(nameof(BackupPackage.XmlStructure.Attributes.TempDirectoryPath), GetRootElement(),""); | ||
337 | var bpxmllist = GetAllXElements(nameof(BackupPackage.XmlStructure.BackupPackage)); | 340 | var bpxmllist = GetAllXElements(nameof(BackupPackage.XmlStructure.BackupPackage)); |
338 | if (bpxmllist != null && bpxmllist.Any()) | 341 | if (bpxmllist != null && bpxmllist.Any()) |
339 | { | 342 | { |
340 | - foreach (var bpxml in bpxmllist) { var bp = new BackupPackage(bpxml); if (bp.Valid) { _backuppackagelist.Add(bp); } } | 343 | + foreach (var bpxml in bpxmllist) { var bp = new BackupPackage(bpxml, tmpdirpath); if (bp.Valid) { _backuppackagelist.Add(bp); } } |
341 | } | 344 | } |
342 | } | 345 | } |
343 | #endregion constructor | 346 | #endregion constructor |
@@ -356,6 +359,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -356,6 +359,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
356 | public string Xml_PackageName; | 359 | public string Xml_PackageName; |
357 | public string Xml_Description; | 360 | public string Xml_Description; |
358 | public string Xml_PackageFilePath; | 361 | public string Xml_PackageFilePath; |
362 | + public string Xml_TempDirectoryPath; | ||
359 | public string Xml_SourceIncludeFilenameMaskList; | 363 | public string Xml_SourceIncludeFilenameMaskList; |
360 | public bool Xml_CreateExe; | 364 | public bool Xml_CreateExe; |
361 | public List<BackupFolder> Xml_BackupFolderList; | 365 | public List<BackupFolder> Xml_BackupFolderList; |
@@ -369,7 +373,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -369,7 +373,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
369 | #endregion basic constructor | 373 | #endregion basic constructor |
370 | 374 | ||
371 | #region xml constructor | 375 | #region xml constructor |
372 | - public BackupPackage(XElement backupackagexml) | 376 | + public BackupPackage(XElement backupackagexml,string tmpdirectorypath) |
373 | { | 377 | { |
374 | Valid = true; | 378 | Valid = true; |
375 | string ATTRIBUTEMANDATORY = nameof(XmlStructure.BackupPackage) + " attribute is mandatory! Name: {0}"; | 379 | string ATTRIBUTEMANDATORY = nameof(XmlStructure.BackupPackage) + " attribute is mandatory! Name: {0}"; |
@@ -379,6 +383,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -379,6 +383,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
379 | Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName); | 383 | Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName); |
380 | Xml_PackageFilePath = GetValue(nameof(XmlStructure.BackupPackage.Attributes.PackageFilePath), backupackagexml, ""); | 384 | Xml_PackageFilePath = GetValue(nameof(XmlStructure.BackupPackage.Attributes.PackageFilePath), backupackagexml, ""); |
381 | if (string.IsNullOrWhiteSpace(Xml_PackageFilePath)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, XmlStructure.BackupPackage.Attributes.PackageFilePath.Values.DEFAULT)); } | 385 | if (string.IsNullOrWhiteSpace(Xml_PackageFilePath)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, XmlStructure.BackupPackage.Attributes.PackageFilePath.Values.DEFAULT)); } |
386 | + Xml_TempDirectoryPath = tmpdirectorypath; | ||
382 | 387 | ||
383 | Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT); | 388 | Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT); |
384 | 389 | ||
@@ -412,36 +417,41 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -412,36 +417,41 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
412 | Xml_Description = bp.Xml_Description; | 417 | Xml_Description = bp.Xml_Description; |
413 | Xml_BackupFolderList = bp.Xml_BackupFolderList.Select(c=>new BackupFolder(c)).ToList(); ; | 418 | Xml_BackupFolderList = bp.Xml_BackupFolderList.Select(c=>new BackupFolder(c)).ToList(); ; |
414 | Xml_PackageFilePath=bp.Xml_PackageFilePath; | 419 | Xml_PackageFilePath=bp.Xml_PackageFilePath; |
420 | + Xml_TempDirectoryPath = bp.Xml_TempDirectoryPath; | ||
415 | Xml_BackupSQLDataBaseList = bp.Xml_BackupSQLDataBaseList.Select(c => new BackupSQLDataBase(c)).ToList(); ; | 421 | Xml_BackupSQLDataBaseList = bp.Xml_BackupSQLDataBaseList.Select(c => new BackupSQLDataBase(c)).ToList(); ; |
416 | Xml_SourceIncludeFilenameMaskList = bp.Xml_SourceIncludeFilenameMaskList; | 422 | Xml_SourceIncludeFilenameMaskList = bp.Xml_SourceIncludeFilenameMaskList; |
417 | - } | ||
418 | - #endregion cloner constructor | 423 | + } |
424 | + #endregion cloner constructor | ||
419 | 425 | ||
420 | #region XmlStructure | 426 | #region XmlStructure |
421 | public static class XmlStructure | 427 | public static class XmlStructure |
428 | + { | ||
429 | + public static class Attributes | ||
422 | { | 430 | { |
423 | - public static class BackupPackage | 431 | + public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } } |
432 | + } | ||
433 | + public static class BackupPackage | ||
434 | + { | ||
435 | + public static class Attributes | ||
436 | + { | ||
437 | + public static class Key { public static class Values { public const string DEFAULT = ""; } } | ||
438 | + public static class Name { } | ||
439 | + public static class Description { } | ||
440 | + public static class CreateExe { public static class Values { public const bool DEFAULT = true; } } | ||
441 | + public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } } | ||
442 | + public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } } | ||
443 | + } | ||
444 | + public static class BackupFolder | ||
424 | { | 445 | { |
425 | public static class Attributes | 446 | public static class Attributes |
426 | { | 447 | { |
427 | - public static class Key { public static class Values { public const string DEFAULT = ""; } } | ||
428 | - public static class Name { } | 448 | + public static class Path { public static class Values { public const string DEFAULT = ""; } } |
429 | public static class Description { } | 449 | public static class Description { } |
430 | - public static class CreateExe { public static class Values { public const bool DEFAULT = true; } } | ||
431 | - public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } } | ||
432 | - public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } } | ||
433 | - } | ||
434 | - public static class BackupFolder | ||
435 | - { | ||
436 | - public static class Attributes | ||
437 | - { | ||
438 | - public static class Path { public static class Values { public const string DEFAULT = ""; } } | ||
439 | - public static class Description { } | ||
440 | - public static class BackupToFile { } | ||
441 | - public static class IncludeNameMask { public class Values { public const string DEFAULT = "*"; } } | ||
442 | - public static class IncludePathRegexp { public class Values { public const string DEFAULT = ".*"; } } | ||
443 | - } | 450 | + public static class BackupToFile { } |
451 | + public static class IncludeNameMask { public class Values { public const string DEFAULT = "*"; } } | ||
452 | + public static class IncludePathRegexp { public class Values { public const string DEFAULT = ".*"; } } | ||
444 | } | 453 | } |
454 | + } | ||
445 | public static class BackupSQLDataBase | 455 | public static class BackupSQLDataBase |
446 | { | 456 | { |
447 | public static class Attributes | 457 | public static class Attributes |
@@ -512,6 +522,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | @@ -512,6 +522,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS | ||
512 | } | 522 | } |
513 | } | 523 | } |
514 | #endregion BackupFolder class | 524 | #endregion BackupFolder class |
525 | + | ||
515 | #region BackupSQLDataBase class | 526 | #region BackupSQLDataBase class |
516 | public class BackupSQLDataBase : XmlLinqBase | 527 | public class BackupSQLDataBase : XmlLinqBase |
517 | { | 528 | { |
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.2.3.0")] | ||
36 | -[assembly: AssemblyFileVersion("1.2.3.0")] | 35 | +[assembly: AssemblyVersion("1.2.4.0")] |
36 | +[assembly: AssemblyFileVersion("1.2.4.0")] |