(feature): get status and fine tuning improvements
This commit is contained in:
parent
5734fa9043
commit
4826d124f7
@ -59,6 +59,11 @@ public class Application {
|
|||||||
Console.WriteLine("Tape ejected.");
|
Console.WriteLine("Tape ejected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetDeviceStatus() {
|
||||||
|
using var handler = new TapeDeviceHandler(_tapePath);
|
||||||
|
handler.GetStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void PathAccessWrapper(WorkingFolder workingFolder, Action<string> myAction) {
|
public void PathAccessWrapper(WorkingFolder workingFolder, Action<string> myAction) {
|
||||||
|
|
||||||
@ -150,7 +155,7 @@ public class Application {
|
|||||||
|
|
||||||
for (int i = 0; i < blocks; i++) {
|
for (int i = 0; i < blocks; i++) {
|
||||||
handler.WriteData(new byte[blockSize]);
|
handler.WriteData(new byte[blockSize]);
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(_configuration.WriteDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,13 +206,14 @@ public class Application {
|
|||||||
}
|
}
|
||||||
handler.WriteData(buffer);
|
handler.WriteData(buffer);
|
||||||
currentTapeBlock++;
|
currentTapeBlock++;
|
||||||
Thread.Sleep(100); // Small delay between blocks
|
Thread.Sleep(_configuration.WriteDelay); // Small delay between blocks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// write mark to indicate end of files
|
// write mark to indicate end of files
|
||||||
handler.WriteMarks(TapeDeviceHandler.TAPE_FILEMARKS, 1);
|
handler.WriteMarks(TapeDeviceHandler.TAPE_FILEMARKS, 1);
|
||||||
|
Thread.Sleep(_configuration.WriteDelay);
|
||||||
|
|
||||||
// write descriptor to tape
|
// write descriptor to tape
|
||||||
var descriptorData = Encoding.UTF8.GetBytes(descriptorJson);
|
var descriptorData = Encoding.UTF8.GetBytes(descriptorJson);
|
||||||
@ -219,7 +225,7 @@ public class Application {
|
|||||||
Array.Copy(descriptorData, startIndex, block, 0, length);
|
Array.Copy(descriptorData, startIndex, block, 0, length);
|
||||||
handler.WriteData(block);
|
handler.WriteData(block);
|
||||||
currentTapeBlock++;
|
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
|
// write 3 0 filled blocks to indicate end of backup
|
||||||
@ -396,7 +402,7 @@ public class Application {
|
|||||||
Console.WriteLine("\nSelect a backup to perform:");
|
Console.WriteLine("\nSelect a backup to perform:");
|
||||||
for (int i = 0; i < _configuration.Backups.Count; i++) {
|
for (int i = 0; i < _configuration.Backups.Count; i++) {
|
||||||
var backupInt = _configuration.Backups[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): ");
|
Console.Write("Enter your choice (or '0' to go back): ");
|
||||||
@ -437,7 +443,7 @@ public class Application {
|
|||||||
Console.WriteLine("\nSelect a backup to restore:");
|
Console.WriteLine("\nSelect a backup to restore:");
|
||||||
for (int i = 0; i < _configuration.Backups.Count; i++) {
|
for (int i = 0; i < _configuration.Backups.Count; i++) {
|
||||||
var backupInt = _configuration.Backups[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): ");
|
Console.Write("Enter your choice (or '0' to go back): ");
|
||||||
|
|||||||
@ -35,5 +35,6 @@ public class BackupItem {
|
|||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
public required string TapePath { get; set; }
|
public required string TapePath { get; set; }
|
||||||
|
public required int WriteDelay { get; set; }
|
||||||
public required List<BackupItem> Backups { get; set; }
|
public required List<BackupItem> Backups { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,8 +18,9 @@ class Program {
|
|||||||
Console.WriteLine("2. Backup");
|
Console.WriteLine("2. Backup");
|
||||||
Console.WriteLine("3. Restore");
|
Console.WriteLine("3. Restore");
|
||||||
Console.WriteLine("4. Eject tape");
|
Console.WriteLine("4. Eject tape");
|
||||||
Console.WriteLine("5. Reload configurations");
|
Console.WriteLine("5. Get device status");
|
||||||
Console.WriteLine("6. Exit");
|
Console.WriteLine("6. Reload configurations");
|
||||||
|
Console.WriteLine("7. Exit");
|
||||||
Console.Write("Enter your choice: ");
|
Console.Write("Enter your choice: ");
|
||||||
|
|
||||||
var choice = Console.ReadLine();
|
var choice = Console.ReadLine();
|
||||||
@ -38,11 +39,13 @@ class Program {
|
|||||||
case "4":
|
case "4":
|
||||||
app.EjectTape();
|
app.EjectTape();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "5":
|
case "5":
|
||||||
app.LoadConfiguration();
|
app.GetDeviceStatus();
|
||||||
break;
|
break;
|
||||||
case "6":
|
case "6":
|
||||||
|
app.LoadConfiguration();
|
||||||
|
break;
|
||||||
|
case "7":
|
||||||
Console.WriteLine("Exiting...");
|
Console.WriteLine("Exiting...");
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"TapePath": "\\\\.\\Tape0",
|
"TapePath": "\\\\.\\Tape0",
|
||||||
|
"WriteDelay": 100,
|
||||||
"Backups": [
|
"Backups": [
|
||||||
{
|
{
|
||||||
"Name": "Normal test",
|
"Name": "Normal test",
|
||||||
@ -7,7 +8,7 @@
|
|||||||
"LTOGen": "LTO5",
|
"LTOGen": "LTO5",
|
||||||
"Source": {
|
"Source": {
|
||||||
"LocalPath": {
|
"LocalPath": {
|
||||||
"Path": "D:\\Drivers"
|
"Path": "F:\\LTO\\Backup"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Destination": {
|
"Destination": {
|
||||||
@ -22,17 +23,17 @@
|
|||||||
"LTOGen": "LTO5",
|
"LTOGen": "LTO5",
|
||||||
"Source": {
|
"Source": {
|
||||||
"RemotePath": {
|
"RemotePath": {
|
||||||
"Path": "\\\\nasrv0001.corp.maks-it.com\\LTO\\Backup",
|
"Path": "\\\\nasrv0002.corp.maks-it.com\\Users",
|
||||||
"Credentials": {
|
"Credentials": {
|
||||||
"Username": "user",
|
"Username": "maksym",
|
||||||
"Password": "password"
|
"Password": "05Train0888"
|
||||||
}
|
},
|
||||||
|
"Protocol": "SMB"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Destination": {
|
"Destination": {
|
||||||
"Path": "F:\\LTO\\Restore"
|
"Path": "F:\\LTO\\Restore\\Users"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user