Compare commits

...

2 Commits

4 changed files with 27 additions and 16 deletions

View File

@ -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<string> myAction) {
@ -150,7 +155,7 @@ public class Application {
for (int i = 0; i < blocks; i++) {
handler.WriteData(new byte[blockSize]);
handler.WaitForTapeReady();
Thread.Sleep(_configuration.WriteDelay);
}
}
@ -201,13 +206,14 @@ public class Application {
}
handler.WriteData(buffer);
currentTapeBlock++;
handler.WaitForTapeReady();
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++;
handler.WaitForTapeReady();
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): ");

View File

@ -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<BackupItem> Backups { get; set; }
}

View File

@ -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:

View File

@ -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": "",
"Password": ""
},
"Protocol": "SMB"
}
},
"Destination": {
"Path": "F:\\LTO\\Restore"
"Path": "F:\\LTO\\Restore\\Users"
}
}
}
]
}