From ba0d08a89edb6e731bd9f81e61be38ec7e4117f2 Mon Sep 17 00:00:00 2001 From: Maksym Sadovnychyy Date: Fri, 1 Nov 2024 10:14:27 -0700 Subject: [PATCH] (feature): Backup from SMB tested --- README.md | 102 ++++++++++++++++++----- src/MaksIT.LTO.Backup/Configuration.cs | 2 +- src/MaksIT.LTO.Backup/configuration.json | 12 +-- 3 files changed, 90 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 776a030..3c325c6 100644 --- a/README.md +++ b/README.md @@ -21,23 +21,52 @@ A C# application designed to facilitate backup and restore operations to an LTO 1. Clone the repository: ```bash - git clone https://github.com/your-username/MaksIT.LTO.Backup.git + git clone https://github.com/MAKS-IT-COM/maksit-lto-backup ``` -2. Ensure `.NET Core` is installed on your system. +2. Ensure `.NET8 SDK` is installed on your system. 3. Prepare a `configuration.json` file in the application directory with the following structure: ```json - { - "TapePath": "YourTapePath", - "Backups": [ - { - "Name": "BackupName", - "Barcode": "123456", - "Source": "path/to/source", - "Destination": "path/to/destination", - "LTOGen": "LTO6" - } - ] - } + { + "TapePath": "\\\\.\\Tape0", + "WriteDelay": 100, + "Backups": [ + { + "Name": "Normal test", + "Barcode": "", + "LTOGen": "LTO5", + "Source": { + "LocalPath": { + "Path": "F:\\LTO\\Backup" + } + }, + "Destination": { + "LocalPath": { + "Path": "F:\\LTO\\Restore" + } + } + }, + { + "Name": "Network test", + "Barcode": "", + "LTOGen": "LTO5", + "Source": { + "RemotePath": { + "Path": "\\\\nassrv0001.corp.maks-it.com\\data-1\\Users", + "PasswordCredentials": { + "Username": "", + "Password": "" + }, + "Protocol": "SMB" + } + }, + "Destination": { + "LocalPath": { + "Path": "F:\\LTO\\Restore" + } + } + } + ] + } ``` ## Usage @@ -57,7 +86,11 @@ Upon running, the following options will be presented: 2. **Backup**: Prompts the user to select a backup task from the configured list and initiates the backup process. 3. **Restore**: Restores a previously backed-up directory from the tape. 4. **Eject Tape**: Ejects the tape from the drive safely. -5. **Exit**: Exits the application. +5. **Get device status**: Mostly used for debugging to understand if device is able to write +6. **Tape Erase (Short)**: +7. **Reload configurations** +6. **Exit**: Exits the application. + ### Code Overview @@ -72,13 +105,42 @@ Below is an example configuration setup for an LTO-6 tape generation backup oper ```json { "TapePath": "\\\\.\\Tape0", + "WriteDelay": 100, "Backups": [ { - "Name": "Monthly Backup", - "Barcode": "MB12345", - "Source": "/path/to/source", - "Destination": "/path/to/restore", - "LTOGen": "LTO6" + "Name": "Normal test", + "Barcode": "", + "LTOGen": "LTO5", + "Source": { + "LocalPath": { + "Path": "F:\\LTO\\Backup" + } + }, + "Destination": { + "LocalPath": { + "Path": "F:\\LTO\\Restore" + } + } + }, + { + "Name": "Network test", + "Barcode": "", + "LTOGen": "LTO5", + "Source": { + "RemotePath": { + "Path": "\\\\nassrv0001.corp.maks-it.com\\data-1\\Users", + "PasswordCredentials": { + "Username": "", + "Password": "" + }, + "Protocol": "SMB" + } + }, + "Destination": { + "LocalPath": { + "Path": "F:\\LTO\\Restore\\Users" + } + } } ] } diff --git a/src/MaksIT.LTO.Backup/Configuration.cs b/src/MaksIT.LTO.Backup/Configuration.cs index afecb5b..4ec91fe 100644 --- a/src/MaksIT.LTO.Backup/Configuration.cs +++ b/src/MaksIT.LTO.Backup/Configuration.cs @@ -12,7 +12,7 @@ public class LocalPath : PathBase { public class PasswordCredentials { public required string Username { get; set; } - public required SecureString Password { get; set; } + public required string Password { get; set; } } public class RemotePath : PathBase { diff --git a/src/MaksIT.LTO.Backup/configuration.json b/src/MaksIT.LTO.Backup/configuration.json index 45f8825..f41b3b3 100644 --- a/src/MaksIT.LTO.Backup/configuration.json +++ b/src/MaksIT.LTO.Backup/configuration.json @@ -1,6 +1,6 @@ { "TapePath": "\\\\.\\Tape0", - "WriteDelay": 1000, + "WriteDelay": 100, "Backups": [ { "Name": "Normal test", @@ -8,7 +8,7 @@ "LTOGen": "LTO5", "Source": { "LocalPath": { - "Path": "D:\\Program Files" + "Path": "F:\\LTO\\Backup" } }, "Destination": { @@ -23,8 +23,8 @@ "LTOGen": "LTO5", "Source": { "RemotePath": { - "Path": "\\\\nasrv0002.corp.maks-it.com\\Users", - "Credentials": { + "Path": "\\\\nassrv0002.corp.maks-it.com\\data-1\\Users", + "PasswordCredentials": { "Username": "", "Password": "" }, @@ -32,7 +32,9 @@ } }, "Destination": { - "Path": "F:\\LTO\\Restore\\Users" + "LocalPath": { + "Path": "F:\\LTO\\Restore" + } } } ]