diff --git a/src/MaksIT.LTO.Backup/Application.cs b/src/MaksIT.LTO.Backup/Application.cs index f6738c8..2049dfc 100644 --- a/src/MaksIT.LTO.Backup/Application.cs +++ b/src/MaksIT.LTO.Backup/Application.cs @@ -59,6 +59,11 @@ public class Application { Console.WriteLine("Tape ejected."); } + public void GetDeviceStatus() { + using var handler = new TapeDeviceHandler(_tapePath); + handler.GetStatus(); + } + public void PathAccessWrapper(WorkingFolder workingFolder, Action myAction) { @@ -150,7 +155,7 @@ public class Application { for (int i = 0; i < blocks; i++) { handler.WriteData(new byte[blockSize]); - Thread.Sleep(100); + Thread.Sleep(_configuration.WriteDelay); } } @@ -201,13 +206,14 @@ public class Application { } handler.WriteData(buffer); currentTapeBlock++; - Thread.Sleep(100); // Small delay between blocks + Thread.Sleep(_configuration.WriteDelay); // Small delay between blocks } } // write mark to indicate end of files handler.WriteMarks(TapeDeviceHandler.TAPE_FILEMARKS, 1); + Thread.Sleep(_configuration.WriteDelay); // write descriptor to tape var descriptorData = Encoding.UTF8.GetBytes(descriptorJson); @@ -219,7 +225,7 @@ public class Application { Array.Copy(descriptorData, startIndex, block, 0, length); handler.WriteData(block); currentTapeBlock++; - Thread.Sleep(100); // Small delay between blocks + Thread.Sleep(_configuration.WriteDelay); // Small delay between blocks } // write 3 0 filled blocks to indicate end of backup @@ -396,7 +402,7 @@ public class Application { Console.WriteLine("\nSelect a backup to perform:"); for (int i = 0; i < _configuration.Backups.Count; i++) { var backupInt = _configuration.Backups[i]; - Console.WriteLine($"{i + 1}. Backup Name: {backupInt.Name}, Bar code {backupInt.Barcode}, Source: {backupInt.Source}, Destination: {backupInt.Destination}"); + Console.WriteLine($"{i + 1}. Backup Name: {backupInt.Name}, Bar code {(string.IsNullOrEmpty(backupInt.Barcode) ? "None" : backupInt.Barcode)}, Source: {backupInt.Source}, Destination: {backupInt.Destination}"); } Console.Write("Enter your choice (or '0' to go back): "); @@ -437,7 +443,7 @@ public class Application { Console.WriteLine("\nSelect a backup to restore:"); for (int i = 0; i < _configuration.Backups.Count; i++) { var backupInt = _configuration.Backups[i]; - Console.WriteLine($"{i + 1}. Backup Name: {backupInt.Name}, Bar code {backupInt.Barcode}, Source: {backupInt.Source}, Destination: {backupInt.Destination}"); + Console.WriteLine($"{i + 1}. Backup Name: {backupInt.Name}, Bar code {(string.IsNullOrEmpty(backupInt.Barcode) ? "None" : backupInt.Barcode)}, Source: {backupInt.Source}, Destination: {backupInt.Destination}"); } Console.Write("Enter your choice (or '0' to go back): "); diff --git a/src/MaksIT.LTO.Backup/Configuration.cs b/src/MaksIT.LTO.Backup/Configuration.cs index e29bcd8..afecb5b 100644 --- a/src/MaksIT.LTO.Backup/Configuration.cs +++ b/src/MaksIT.LTO.Backup/Configuration.cs @@ -35,5 +35,6 @@ public class BackupItem { public class Configuration { public required string TapePath { get; set; } + public required int WriteDelay { get; set; } public required List Backups { get; set; } } diff --git a/src/MaksIT.LTO.Backup/Program.cs b/src/MaksIT.LTO.Backup/Program.cs index 52f9cc5..85fceda 100644 --- a/src/MaksIT.LTO.Backup/Program.cs +++ b/src/MaksIT.LTO.Backup/Program.cs @@ -18,8 +18,9 @@ class Program { Console.WriteLine("2. Backup"); Console.WriteLine("3. Restore"); Console.WriteLine("4. Eject tape"); - Console.WriteLine("5. Reload configurations"); - Console.WriteLine("6. Exit"); + Console.WriteLine("5. Get device status"); + Console.WriteLine("6. Reload configurations"); + Console.WriteLine("7. Exit"); Console.Write("Enter your choice: "); var choice = Console.ReadLine(); @@ -38,11 +39,13 @@ class Program { case "4": app.EjectTape(); break; - case "5": - app.LoadConfiguration(); + app.GetDeviceStatus(); break; case "6": + app.LoadConfiguration(); + break; + case "7": Console.WriteLine("Exiting..."); return; default: diff --git a/src/MaksIT.LTO.Backup/configuration.json b/src/MaksIT.LTO.Backup/configuration.json index b320264..c0fff25 100644 --- a/src/MaksIT.LTO.Backup/configuration.json +++ b/src/MaksIT.LTO.Backup/configuration.json @@ -1,5 +1,6 @@ { "TapePath": "\\\\.\\Tape0", + "WriteDelay": 100, "Backups": [ { "Name": "Normal test", @@ -7,7 +8,7 @@ "LTOGen": "LTO5", "Source": { "LocalPath": { - "Path": "D:\\Drivers" + "Path": "F:\\LTO\\Backup" } }, "Destination": { @@ -22,17 +23,17 @@ "LTOGen": "LTO5", "Source": { "RemotePath": { - "Path": "\\\\nasrv0001.corp.maks-it.com\\LTO\\Backup", + "Path": "\\\\nasrv0002.corp.maks-it.com\\Users", "Credentials": { - "Username": "user", - "Password": "password" - } + "Username": "maksym", + "Password": "05Train0888" + }, + "Protocol": "SMB" } }, "Destination": { - "Path": "F:\\LTO\\Restore" + "Path": "F:\\LTO\\Restore\\Users" } } -} ] } \ No newline at end of file